From 950ae6546e295d7df2959dee72c77c750f4b97b2 Mon Sep 17 00:00:00 2001 From: Lubos Date: Tue, 2 Sep 2025 20:22:05 +0800 Subject: [PATCH 1/5] feat: symbol api --- .../codegen-core/src/__tests__/file.test.ts | 53 +- packages/codegen-core/src/__tests__/file.ts | 11 + .../src/__tests__/project.test.ts | 34 +- .../src/__tests__/renderer.test.ts | 37 + packages/codegen-core/src/bimap/bimap.ts | 64 + packages/codegen-core/src/bimap/types.d.ts | 74 + packages/codegen-core/src/files/file.ts | 146 +- packages/codegen-core/src/files/types.d.ts | 63 +- packages/codegen-core/src/index.ts | 9 +- packages/codegen-core/src/project/project.ts | 163 +- packages/codegen-core/src/project/types.d.ts | 64 +- .../codegen-core/src/renderers/renderer.ts | 38 + .../codegen-core/src/renderers/types.d.ts | 28 +- packages/codegen-core/src/symbols/types.d.ts | 131 +- packages/custom-client/package.json | 2 + packages/custom-client/src/plugin.ts | 28 +- packages/openapi-ts-tests/main/package.json | 1 + .../additional-properties-false/index.ts | 3 +- .../additional-properties-false/types.gen.ts | 2 +- .../2.0.x/additional-properties-true/index.ts | 3 +- .../additional-properties-true/types.gen.ts | 2 +- .../body-response-text-plain/client.gen.ts | 4 +- .../2.0.x/body-response-text-plain/index.ts | 3 +- .../2.0.x/body-response-text-plain/sdk.gen.ts | 8 +- .../body-response-text-plain/types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../2.0.x/enum-names-values/index.ts | 3 +- .../2.0.x/enum-names-values/types.gen.ts | 2 +- .../2.0.x/exclude-deprecated/index.ts | 3 +- .../2.0.x/exclude-deprecated/types.gen.ts | 2 +- .../2.0.x/form-data/client.gen.ts | 4 +- .../__snapshots__/2.0.x/form-data/index.ts | 3 +- .../__snapshots__/2.0.x/form-data/sdk.gen.ts | 8 +- .../2.0.x/form-data/types.gen.ts | 2 +- .../sdk-nested-classes-instance/client.gen.ts | 4 +- .../sdk-nested-classes-instance/index.ts | 3 +- .../sdk-nested-classes-instance/sdk.gen.ts | 8 +- .../sdk-nested-classes-instance/types.gen.ts | 2 +- .../sdk-nested-classes/client.gen.ts | 4 +- .../client-fetch/sdk-nested-classes/index.ts | 3 +- .../sdk-nested-classes/sdk.gen.ts | 16 +- .../sdk-nested-classes/types.gen.ts | 2 +- .../@hey-api/schemas/default/schemas.gen.ts | 2 +- .../@hey-api/sdk/default/client.gen.ts | 4 +- .../plugins/@hey-api/sdk/default/index.ts | 3 +- .../plugins/@hey-api/sdk/default/sdk.gen.ts | 74 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 2 +- .../@hey-api/sdk/instance/client.gen.ts | 4 +- .../plugins/@hey-api/sdk/instance/index.ts | 3 +- .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 8 +- .../@hey-api/sdk/instance/types.gen.ts | 2 +- .../@hey-api/sdk/throwOnError/client.gen.ts | 4 +- .../@hey-api/sdk/throwOnError/index.ts | 3 +- .../@hey-api/sdk/throwOnError/sdk.gen.ts | 74 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 2 +- .../type-format-valibot/client.gen.ts | 4 +- .../transformers/type-format-valibot/index.ts | 3 +- .../type-format-valibot/sdk.gen.ts | 15 +- .../type-format-valibot/transformers.gen.ts | 2 +- .../type-format-valibot/types.gen.ts | 2 +- .../type-format-valibot/valibot.gen.ts | 2 +- .../type-format-zod/client.gen.ts | 4 +- .../transformers/type-format-zod/index.ts | 3 +- .../transformers/type-format-zod/sdk.gen.ts | 8 +- .../type-format-zod/transformers.gen.ts | 2 +- .../transformers/type-format-zod/types.gen.ts | 2 +- .../transformers/type-format-zod/zod.gen.ts | 2 +- .../client.gen.ts | 4 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../client.gen.ts | 4 +- .../transforms-read-write-ignore/index.ts | 3 +- .../transforms-read-write-ignore/types.gen.ts | 2 +- .../@pinia/colada/fetch/@pinia/colada.gen.ts | 6 +- .../plugins/@pinia/colada/fetch/client.gen.ts | 4 +- .../plugins/@pinia/colada/fetch/index.ts | 3 +- .../plugins/@pinia/colada/fetch/sdk.gen.ts | 74 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 2 +- .../@pinia/colada/CollectionFormat.gen.ts | 56 - .../group-by-tag/@pinia/colada/Complex.gen.ts | 56 - .../@pinia/colada/Defaults.gen.ts | 82 - .../@pinia/colada/Descriptions.gen.ts | 18 - .../@pinia/colada/Duplicate.gen.ts | 95 - .../group-by-tag/@pinia/colada/Error.gen.ts | 18 - .../group-by-tag/@pinia/colada/Header.gen.ts | 18 - .../@pinia/colada/MultipleTags1.gen.ts | 72 - .../@pinia/colada/NoContent.gen.ts | 56 - ...05\303\266\303\264\303\252\303\212.gen.ts" | 18 - .../@pinia/colada/Parameters.gen.ts | 31 - .../@pinia/colada/Response.gen.ts | 98 - .../group-by-tag/@pinia/colada/Simple.gen.ts | 108 - .../group-by-tag/@pinia/colada/Types.gen.ts | 56 - .../group-by-tag/@pinia/colada/default.gen.ts | 99 - .../@pinia/colada/group-by-tag/client.gen.ts | 18 - .../colada/group-by-tag/client/client.gen.ts | 267 --- .../colada/group-by-tag/client/index.ts | 25 - .../colada/group-by-tag/client/types.gen.ts | 268 --- .../colada/group-by-tag/client/utils.gen.ts | 327 --- .../colada/group-by-tag/core/auth.gen.ts | 42 - .../group-by-tag/core/bodySerializer.gen.ts | 92 - .../colada/group-by-tag/core/params.gen.ts | 153 -- .../group-by-tag/core/pathSerializer.gen.ts | 181 -- .../group-by-tag/core/serverSentEvents.gen.ts | 264 --- .../colada/group-by-tag/core/types.gen.ts | 118 - .../colada/group-by-tag/core/utils.gen.ts | 114 - .../@pinia/colada/group-by-tag/index.ts | 3 - .../@pinia/colada/group-by-tag/sdk.gen.ts | 277 --- .../@pinia/colada/group-by-tag/types.gen.ts | 1179 ---------- .../angular-query-experimental.gen.ts | 8 +- .../asClass/client.gen.ts | 4 +- .../asClass/index.ts | 3 +- .../asClass/sdk.gen.ts | 18 +- .../asClass/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 6 +- .../axios/client.gen.ts | 4 +- .../angular-query-experimental/axios/index.ts | 3 +- .../axios/sdk.gen.ts | 74 +- .../axios/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 6 +- .../fetch/client.gen.ts | 4 +- .../angular-query-experimental/fetch/index.ts | 3 +- .../fetch/sdk.gen.ts | 74 +- .../fetch/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 6 +- .../name-builder/client.gen.ts | 4 +- .../name-builder/index.ts | 3 +- .../name-builder/sdk.gen.ts | 18 +- .../name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/react-query.gen.ts | 8 +- .../react-query/asClass/client.gen.ts | 4 +- .../@tanstack/react-query/asClass/index.ts | 3 +- .../@tanstack/react-query/asClass/sdk.gen.ts | 18 +- .../react-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/react-query.gen.ts | 6 +- .../@tanstack/react-query/axios/client.gen.ts | 4 +- .../@tanstack/react-query/axios/index.ts | 3 +- .../@tanstack/react-query/axios/sdk.gen.ts | 74 +- .../@tanstack/react-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/react-query.gen.ts | 6 +- .../@tanstack/react-query/fetch/client.gen.ts | 4 +- .../@tanstack/react-query/fetch/index.ts | 3 +- .../@tanstack/react-query/fetch/sdk.gen.ts | 74 +- .../@tanstack/react-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/react-query.gen.ts | 6 +- .../react-query/name-builder/client.gen.ts | 4 +- .../react-query/name-builder/index.ts | 3 +- .../react-query/name-builder/sdk.gen.ts | 18 +- .../react-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/solid-query.gen.ts | 8 +- .../solid-query/asClass/client.gen.ts | 4 +- .../@tanstack/solid-query/asClass/index.ts | 3 +- .../@tanstack/solid-query/asClass/sdk.gen.ts | 18 +- .../solid-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/solid-query.gen.ts | 6 +- .../@tanstack/solid-query/axios/client.gen.ts | 4 +- .../@tanstack/solid-query/axios/index.ts | 3 +- .../@tanstack/solid-query/axios/sdk.gen.ts | 74 +- .../@tanstack/solid-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/solid-query.gen.ts | 6 +- .../@tanstack/solid-query/fetch/client.gen.ts | 4 +- .../@tanstack/solid-query/fetch/index.ts | 3 +- .../@tanstack/solid-query/fetch/sdk.gen.ts | 74 +- .../@tanstack/solid-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/solid-query.gen.ts | 6 +- .../solid-query/name-builder/client.gen.ts | 4 +- .../solid-query/name-builder/index.ts | 3 +- .../solid-query/name-builder/sdk.gen.ts | 18 +- .../solid-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/svelte-query.gen.ts | 8 +- .../svelte-query/asClass/client.gen.ts | 4 +- .../@tanstack/svelte-query/asClass/index.ts | 3 +- .../@tanstack/svelte-query/asClass/sdk.gen.ts | 18 +- .../svelte-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/svelte-query.gen.ts | 6 +- .../svelte-query/axios/client.gen.ts | 4 +- .../@tanstack/svelte-query/axios/index.ts | 3 +- .../@tanstack/svelte-query/axios/sdk.gen.ts | 74 +- .../@tanstack/svelte-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/svelte-query.gen.ts | 6 +- .../svelte-query/fetch/client.gen.ts | 4 +- .../@tanstack/svelte-query/fetch/index.ts | 3 +- .../@tanstack/svelte-query/fetch/sdk.gen.ts | 74 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 2 +- .../@tanstack/svelte-query.gen.ts | 6 +- .../svelte-query/name-builder/client.gen.ts | 4 +- .../svelte-query/name-builder/index.ts | 3 +- .../svelte-query/name-builder/sdk.gen.ts | 18 +- .../svelte-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/vue-query.gen.ts | 8 +- .../@tanstack/vue-query/asClass/client.gen.ts | 4 +- .../@tanstack/vue-query/asClass/index.ts | 3 +- .../@tanstack/vue-query/asClass/sdk.gen.ts | 18 +- .../@tanstack/vue-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/vue-query.gen.ts | 6 +- .../@tanstack/vue-query/axios/client.gen.ts | 4 +- .../@tanstack/vue-query/axios/index.ts | 3 +- .../@tanstack/vue-query/axios/sdk.gen.ts | 74 +- .../@tanstack/vue-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/vue-query.gen.ts | 6 +- .../@tanstack/vue-query/fetch/client.gen.ts | 4 +- .../@tanstack/vue-query/fetch/index.ts | 3 +- .../@tanstack/vue-query/fetch/sdk.gen.ts | 74 +- .../@tanstack/vue-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/vue-query.gen.ts | 6 +- .../vue-query/name-builder/client.gen.ts | 4 +- .../@tanstack/vue-query/name-builder/index.ts | 3 +- .../vue-query/name-builder/sdk.gen.ts | 18 +- .../vue-query/name-builder/types.gen.ts | 2 +- .../plugins/fastify/default/fastify.gen.ts | 2 +- .../2.0.x/plugins/fastify/default/index.ts | 3 +- .../plugins/fastify/default/types.gen.ts | 2 +- .../plugins/valibot/default/valibot.gen.ts | 2 +- .../2.0.x/schema-unknown/client.gen.ts | 4 +- .../2.0.x/schema-unknown/index.ts | 3 +- .../2.0.x/schema-unknown/sdk.gen.ts | 8 +- .../2.0.x/schema-unknown/types.gen.ts | 2 +- .../2.0.x/security-api-key/client.gen.ts | 4 +- .../2.0.x/security-api-key/index.ts | 3 +- .../2.0.x/security-api-key/sdk.gen.ts | 8 +- .../2.0.x/security-api-key/types.gen.ts | 2 +- .../2.0.x/security-basic/client.gen.ts | 4 +- .../2.0.x/security-basic/index.ts | 3 +- .../2.0.x/security-basic/sdk.gen.ts | 8 +- .../2.0.x/security-basic/types.gen.ts | 2 +- .../2.0.x/security-false/client.gen.ts | 4 +- .../2.0.x/security-false/index.ts | 3 +- .../2.0.x/security-false/sdk.gen.ts | 8 +- .../2.0.x/security-false/types.gen.ts | 2 +- .../2.0.x/security-oauth2/client.gen.ts | 4 +- .../2.0.x/security-oauth2/index.ts | 3 +- .../2.0.x/security-oauth2/sdk.gen.ts | 8 +- .../2.0.x/security-oauth2/types.gen.ts | 2 +- .../2.0.x/servers-base-path/client.gen.ts | 4 +- .../2.0.x/servers-base-path/index.ts | 3 +- .../2.0.x/servers-base-path/types.gen.ts | 2 +- .../2.0.x/servers-host/client.gen.ts | 4 +- .../__snapshots__/2.0.x/servers-host/index.ts | 3 +- .../2.0.x/servers-host/types.gen.ts | 2 +- .../__snapshots__/2.0.x/servers/client.gen.ts | 4 +- .../test/__snapshots__/2.0.x/servers/index.ts | 3 +- .../__snapshots__/2.0.x/servers/types.gen.ts | 2 +- .../2.0.x/transforms-read-write/client.gen.ts | 4 +- .../2.0.x/transforms-read-write/index.ts | 3 +- .../2.0.x/transforms-read-write/types.gen.ts | 2 +- .../additional-properties-false/index.ts | 3 +- .../additional-properties-false/types.gen.ts | 2 +- .../3.0.x/additional-properties-true/index.ts | 3 +- .../additional-properties-true/types.gen.ts | 2 +- .../additional-properties-undefined/index.ts | 3 +- .../types.gen.ts | 2 +- .../array-items-one-of-length-1/index.ts | 3 +- .../array-items-one-of-length-1/types.gen.ts | 2 +- .../valibot.gen.ts | 2 +- .../3.0.x/array-nested-one-of/index.ts | 3 +- .../3.0.x/array-nested-one-of/types.gen.ts | 2 +- .../body-response-text-plain/client.gen.ts | 4 +- .../3.0.x/body-response-text-plain/index.ts | 3 +- .../3.0.x/body-response-text-plain/sdk.gen.ts | 8 +- .../body-response-text-plain/types.gen.ts | 2 +- .../3.0.x/case-PascalCase/index.ts | 3 +- .../3.0.x/case-PascalCase/types.gen.ts | 2 +- .../3.0.x/case-camelCase/index.ts | 3 +- .../3.0.x/case-camelCase/types.gen.ts | 2 +- .../3.0.x/case-preserve/index.ts | 3 +- .../3.0.x/case-preserve/types.gen.ts | 2 +- .../3.0.x/case-snake_case/index.ts | 3 +- .../3.0.x/case-snake_case/types.gen.ts | 2 +- .../3.0.x/components-request-bodies/index.ts | 3 +- .../components-request-bodies/types.gen.ts | 2 +- .../3.0.x/content-binary/index.ts | 3 +- .../3.0.x/content-binary/types.gen.ts | 2 +- .../3.0.x/content-types/client.gen.ts | 4 +- .../3.0.x/content-types/index.ts | 3 +- .../3.0.x/content-types/sdk.gen.ts | 8 +- .../3.0.x/content-types/types.gen.ts | 2 +- .../3.0.x/discriminator-all-of/index.ts | 3 +- .../3.0.x/discriminator-all-of/types.gen.ts | 2 +- .../3.0.x/discriminator-any-of/index.ts | 3 +- .../3.0.x/discriminator-any-of/types.gen.ts | 2 +- .../3.0.x/discriminator-mapped-many/index.ts | 3 +- .../discriminator-mapped-many/types.gen.ts | 2 +- .../3.0.x/discriminator-one-of/index.ts | 3 +- .../3.0.x/discriminator-one-of/types.gen.ts | 2 +- .../__snapshots__/3.0.x/enum-escape/index.ts | 3 +- .../3.0.x/enum-escape/types.gen.ts | 2 +- .../3.0.x/enum-inline-javascript/index.ts | 3 +- .../3.0.x/enum-inline-javascript/types.gen.ts | 2 +- .../3.0.x/enum-inline-typescript/index.ts | 3 +- .../3.0.x/enum-inline-typescript/types.gen.ts | 2 +- .../__snapshots__/3.0.x/enum-inline/index.ts | 3 +- .../3.0.x/enum-inline/types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../3.0.x/enum-names-values/index.ts | 3 +- .../3.0.x/enum-names-values/types.gen.ts | 2 +- .../__snapshots__/3.0.x/enum-null/index.ts | 3 +- .../3.0.x/enum-null/types.gen.ts | 2 +- .../3.0.x/enum-null/valibot.gen.ts | 2 +- .../3.0.x/exclude-deprecated/index.ts | 3 +- .../3.0.x/exclude-deprecated/types.gen.ts | 2 +- .../@tanstack/react-query.gen.ts | 6 +- .../internal-name-conflict/client.gen.ts | 4 +- .../3.0.x/internal-name-conflict/index.ts | 3 +- .../3.0.x/internal-name-conflict/sdk.gen.ts | 12 +- .../3.0.x/internal-name-conflict/types.gen.ts | 2 +- .../3.0.x/operation-204/index.ts | 3 +- .../3.0.x/operation-204/types.gen.ts | 2 +- .../client.gen.ts | 4 +- .../parameter-explode-false-axios/index.ts | 3 +- .../parameter-explode-false-axios/sdk.gen.ts | 8 +- .../types.gen.ts | 2 +- .../parameter-explode-false/client.gen.ts | 4 +- .../3.0.x/parameter-explode-false/index.ts | 3 +- .../3.0.x/parameter-explode-false/sdk.gen.ts | 8 +- .../parameter-explode-false/types.gen.ts | 2 +- .../sdk-nested-classes-instance/client.gen.ts | 4 +- .../sdk-nested-classes-instance/index.ts | 3 +- .../sdk-nested-classes-instance/sdk.gen.ts | 8 +- .../sdk-nested-classes-instance/types.gen.ts | 2 +- .../sdk-nested-classes/client.gen.ts | 4 +- .../client-fetch/sdk-nested-classes/index.ts | 3 +- .../sdk-nested-classes/sdk.gen.ts | 16 +- .../sdk-nested-classes/types.gen.ts | 2 +- .../@hey-api/schemas/default/schemas.gen.ts | 2 +- .../@hey-api/sdk/default/client.gen.ts | 4 +- .../plugins/@hey-api/sdk/default/index.ts | 3 +- .../plugins/@hey-api/sdk/default/sdk.gen.ts | 106 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 2 +- .../@hey-api/sdk/instance/client.gen.ts | 4 +- .../plugins/@hey-api/sdk/instance/index.ts | 3 +- .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 8 +- .../@hey-api/sdk/instance/types.gen.ts | 2 +- .../@hey-api/sdk/throwOnError/client.gen.ts | 4 +- .../@hey-api/sdk/throwOnError/index.ts | 3 +- .../@hey-api/sdk/throwOnError/sdk.gen.ts | 106 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 2 +- .../type-format-valibot/client.gen.ts | 4 +- .../transformers/type-format-valibot/index.ts | 3 +- .../type-format-valibot/sdk.gen.ts | 15 +- .../type-format-valibot/transformers.gen.ts | 2 +- .../type-format-valibot/types.gen.ts | 2 +- .../type-format-valibot/valibot.gen.ts | 2 +- .../type-format-zod/client.gen.ts | 4 +- .../transformers/type-format-zod/index.ts | 3 +- .../transformers/type-format-zod/sdk.gen.ts | 8 +- .../type-format-zod/transformers.gen.ts | 2 +- .../transformers/type-format-zod/types.gen.ts | 2 +- .../transformers/type-format-zod/zod.gen.ts | 2 +- .../client.gen.ts | 4 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../client.gen.ts | 4 +- .../transforms-read-write-ignore/index.ts | 3 +- .../transforms-read-write-ignore/types.gen.ts | 2 +- .../@pinia/colada/fetch/@pinia/colada.gen.ts | 10 +- .../plugins/@pinia/colada/fetch/client.gen.ts | 4 +- .../plugins/@pinia/colada/fetch/index.ts | 3 +- .../plugins/@pinia/colada/fetch/sdk.gen.ts | 106 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 2 +- .../@pinia/colada/CollectionFormat.gen.ts | 56 - .../group-by-tag/@pinia/colada/Complex.gen.ts | 69 - .../@pinia/colada/Defaults.gen.ts | 82 - .../@pinia/colada/Deprecated.gen.ts | 21 - .../@pinia/colada/Descriptions.gen.ts | 18 - .../@pinia/colada/Duplicate.gen.ts | 95 - .../group-by-tag/@pinia/colada/Error.gen.ts | 18 - .../@pinia/colada/FileResponse.gen.ts | 56 - .../@pinia/colada/FormData.gen.ts | 18 - .../group-by-tag/@pinia/colada/Header.gen.ts | 18 - .../@pinia/colada/MultipleTags1.gen.ts | 72 - .../@pinia/colada/NoContent.gen.ts | 56 - ...05\303\266\303\264\303\252\303\212.gen.ts" | 34 - .../@pinia/colada/Parameters.gen.ts | 108 - .../@pinia/colada/RequestBody.gen.ts | 18 - .../@pinia/colada/Response.gen.ts | 98 - .../group-by-tag/@pinia/colada/Simple.gen.ts | 124 - .../group-by-tag/@pinia/colada/Types.gen.ts | 56 - .../group-by-tag/@pinia/colada/Upload.gen.ts | 18 - .../group-by-tag/@pinia/colada/default.gen.ts | 111 - .../@pinia/colada/multipart.gen.ts | 69 - .../@pinia/colada/group-by-tag/client.gen.ts | 18 - .../colada/group-by-tag/client/client.gen.ts | 267 --- .../colada/group-by-tag/client/index.ts | 25 - .../colada/group-by-tag/client/types.gen.ts | 268 --- .../colada/group-by-tag/client/utils.gen.ts | 327 --- .../colada/group-by-tag/core/auth.gen.ts | 42 - .../group-by-tag/core/bodySerializer.gen.ts | 92 - .../colada/group-by-tag/core/params.gen.ts | 153 -- .../group-by-tag/core/pathSerializer.gen.ts | 181 -- .../group-by-tag/core/serverSentEvents.gen.ts | 264 --- .../colada/group-by-tag/core/types.gen.ts | 118 - .../colada/group-by-tag/core/utils.gen.ts | 114 - .../@pinia/colada/group-by-tag/index.ts | 3 - .../@pinia/colada/group-by-tag/sdk.gen.ts | 409 ---- .../@pinia/colada/group-by-tag/types.gen.ts | 2047 ---------------- .../angular-query-experimental.gen.ts | 8 +- .../asClass/client.gen.ts | 4 +- .../asClass/index.ts | 3 +- .../asClass/sdk.gen.ts | 18 +- .../asClass/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 12 +- .../axios/client.gen.ts | 4 +- .../angular-query-experimental/axios/index.ts | 3 +- .../axios/sdk.gen.ts | 106 +- .../axios/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 12 +- .../fetch/client.gen.ts | 4 +- .../angular-query-experimental/fetch/index.ts | 3 +- .../fetch/sdk.gen.ts | 106 +- .../fetch/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 6 +- .../name-builder/client.gen.ts | 4 +- .../name-builder/index.ts | 3 +- .../name-builder/sdk.gen.ts | 18 +- .../name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/react-query.gen.ts | 8 +- .../react-query/asClass/client.gen.ts | 4 +- .../@tanstack/react-query/asClass/index.ts | 3 +- .../@tanstack/react-query/asClass/sdk.gen.ts | 18 +- .../react-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/react-query.gen.ts | 12 +- .../@tanstack/react-query/axios/client.gen.ts | 4 +- .../@tanstack/react-query/axios/index.ts | 3 +- .../@tanstack/react-query/axios/sdk.gen.ts | 106 +- .../@tanstack/react-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/react-query.gen.ts | 12 +- .../@tanstack/react-query/fetch/client.gen.ts | 4 +- .../@tanstack/react-query/fetch/index.ts | 3 +- .../@tanstack/react-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/react-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/react-query.gen.ts | 6 +- .../react-query/name-builder/client.gen.ts | 4 +- .../react-query/name-builder/index.ts | 3 +- .../react-query/name-builder/sdk.gen.ts | 18 +- .../react-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/solid-query.gen.ts | 8 +- .../solid-query/asClass/client.gen.ts | 4 +- .../@tanstack/solid-query/asClass/index.ts | 3 +- .../@tanstack/solid-query/asClass/sdk.gen.ts | 18 +- .../solid-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/solid-query.gen.ts | 12 +- .../@tanstack/solid-query/axios/client.gen.ts | 4 +- .../@tanstack/solid-query/axios/index.ts | 3 +- .../@tanstack/solid-query/axios/sdk.gen.ts | 106 +- .../@tanstack/solid-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/solid-query.gen.ts | 12 +- .../@tanstack/solid-query/fetch/client.gen.ts | 4 +- .../@tanstack/solid-query/fetch/index.ts | 3 +- .../@tanstack/solid-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/solid-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/solid-query.gen.ts | 6 +- .../solid-query/name-builder/client.gen.ts | 4 +- .../solid-query/name-builder/index.ts | 3 +- .../solid-query/name-builder/sdk.gen.ts | 18 +- .../solid-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/svelte-query.gen.ts | 8 +- .../svelte-query/asClass/client.gen.ts | 4 +- .../@tanstack/svelte-query/asClass/index.ts | 3 +- .../@tanstack/svelte-query/asClass/sdk.gen.ts | 18 +- .../svelte-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/svelte-query.gen.ts | 12 +- .../svelte-query/axios/client.gen.ts | 4 +- .../@tanstack/svelte-query/axios/index.ts | 3 +- .../@tanstack/svelte-query/axios/sdk.gen.ts | 106 +- .../@tanstack/svelte-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/svelte-query.gen.ts | 12 +- .../svelte-query/fetch/client.gen.ts | 4 +- .../@tanstack/svelte-query/fetch/index.ts | 3 +- .../@tanstack/svelte-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 2 +- .../@tanstack/svelte-query.gen.ts | 6 +- .../svelte-query/name-builder/client.gen.ts | 4 +- .../svelte-query/name-builder/index.ts | 3 +- .../svelte-query/name-builder/sdk.gen.ts | 18 +- .../svelte-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/vue-query.gen.ts | 8 +- .../@tanstack/vue-query/asClass/client.gen.ts | 4 +- .../@tanstack/vue-query/asClass/index.ts | 3 +- .../@tanstack/vue-query/asClass/sdk.gen.ts | 18 +- .../@tanstack/vue-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/vue-query.gen.ts | 12 +- .../@tanstack/vue-query/axios/client.gen.ts | 4 +- .../@tanstack/vue-query/axios/index.ts | 3 +- .../@tanstack/vue-query/axios/sdk.gen.ts | 106 +- .../@tanstack/vue-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/vue-query.gen.ts | 12 +- .../@tanstack/vue-query/fetch/client.gen.ts | 4 +- .../@tanstack/vue-query/fetch/index.ts | 3 +- .../@tanstack/vue-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/vue-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/vue-query.gen.ts | 6 +- .../vue-query/name-builder/client.gen.ts | 4 +- .../@tanstack/vue-query/name-builder/index.ts | 3 +- .../vue-query/name-builder/sdk.gen.ts | 18 +- .../vue-query/name-builder/types.gen.ts | 2 +- .../plugins/fastify/default/fastify.gen.ts | 8 +- .../3.0.x/plugins/fastify/default/index.ts | 3 +- .../plugins/fastify/default/types.gen.ts | 2 +- .../plugins/valibot/default/valibot.gen.ts | 2 +- .../3.0.x/security-api-key/client.gen.ts | 4 +- .../3.0.x/security-api-key/index.ts | 3 +- .../3.0.x/security-api-key/sdk.gen.ts | 10 +- .../3.0.x/security-api-key/types.gen.ts | 2 +- .../3.0.x/security-false/client.gen.ts | 4 +- .../3.0.x/security-false/index.ts | 3 +- .../3.0.x/security-false/sdk.gen.ts | 8 +- .../3.0.x/security-false/types.gen.ts | 2 +- .../3.0.x/security-http-bearer/client.gen.ts | 4 +- .../3.0.x/security-http-bearer/index.ts | 3 +- .../3.0.x/security-http-bearer/sdk.gen.ts | 8 +- .../3.0.x/security-http-bearer/types.gen.ts | 2 +- .../3.0.x/security-oauth2/client.gen.ts | 4 +- .../3.0.x/security-oauth2/index.ts | 3 +- .../3.0.x/security-oauth2/sdk.gen.ts | 8 +- .../3.0.x/security-oauth2/types.gen.ts | 2 +- .../security-open-id-connect/client.gen.ts | 4 +- .../3.0.x/security-open-id-connect/index.ts | 3 +- .../3.0.x/security-open-id-connect/sdk.gen.ts | 8 +- .../security-open-id-connect/types.gen.ts | 2 +- .../__snapshots__/3.0.x/servers/client.gen.ts | 4 +- .../test/__snapshots__/3.0.x/servers/index.ts | 3 +- .../__snapshots__/3.0.x/servers/types.gen.ts | 2 +- .../3.0.x/transformers-all-of/client.gen.ts | 4 +- .../3.0.x/transformers-all-of/index.ts | 3 +- .../transformers-all-of/transformers.gen.ts | 2 +- .../3.0.x/transformers-all-of/types.gen.ts | 2 +- .../transformers-any-of-null/client.gen.ts | 4 +- .../3.0.x/transformers-any-of-null/index.ts | 3 +- .../transformers.gen.ts | 2 +- .../transformers-any-of-null/types.gen.ts | 2 +- .../3.0.x/transformers-array/client.gen.ts | 4 +- .../3.0.x/transformers-array/index.ts | 3 +- .../transformers-array/transformers.gen.ts | 2 +- .../3.0.x/transformers-array/types.gen.ts | 2 +- .../3.0.x/transforms-read-write/client.gen.ts | 4 +- .../3.0.x/transforms-read-write/index.ts | 3 +- .../3.0.x/transforms-read-write/types.gen.ts | 2 +- .../__snapshots__/3.0.x/type-invalid/index.ts | 3 +- .../3.0.x/type-invalid/types.gen.ts | 2 +- .../3.0.x/validators/valibot.gen.ts | 2 +- .../additional-properties-false/index.ts | 3 +- .../additional-properties-false/types.gen.ts | 2 +- .../3.1.x/additional-properties-true/index.ts | 3 +- .../additional-properties-true/types.gen.ts | 2 +- .../additional-properties-undefined/index.ts | 3 +- .../types.gen.ts | 2 +- .../array-items-one-of-length-1/index.ts | 3 +- .../array-items-one-of-length-1/types.gen.ts | 2 +- .../valibot.gen.ts | 2 +- .../3.1.x/array-nested-one-of/index.ts | 3 +- .../3.1.x/array-nested-one-of/types.gen.ts | 2 +- .../body-response-text-plain/client.gen.ts | 4 +- .../3.1.x/body-response-text-plain/index.ts | 3 +- .../3.1.x/body-response-text-plain/sdk.gen.ts | 8 +- .../body-response-text-plain/types.gen.ts | 2 +- .../3.1.x/case-PascalCase/index.ts | 3 +- .../3.1.x/case-PascalCase/types.gen.ts | 2 +- .../3.1.x/case-camelCase/index.ts | 3 +- .../3.1.x/case-camelCase/types.gen.ts | 2 +- .../3.1.x/case-preserve/index.ts | 3 +- .../3.1.x/case-preserve/types.gen.ts | 2 +- .../3.1.x/case-snake_case/index.ts | 3 +- .../3.1.x/case-snake_case/types.gen.ts | 2 +- .../client-axios/base-url-false/client.gen.ts | 4 +- .../client-axios/base-url-false/index.ts | 3 +- .../client-axios/base-url-false/types.gen.ts | 2 +- .../base-url-number/client.gen.ts | 4 +- .../client-axios/base-url-number/index.ts | 3 +- .../client-axios/base-url-number/types.gen.ts | 2 +- .../base-url-strict/client.gen.ts | 4 +- .../client-axios/base-url-strict/index.ts | 3 +- .../client-axios/base-url-strict/types.gen.ts | 2 +- .../base-url-string/client.gen.ts | 4 +- .../client-axios/base-url-string/index.ts | 3 +- .../client-axios/base-url-string/types.gen.ts | 2 +- .../client-axios/clean-false/client.gen.ts | 4 +- .../client-axios/clean-false/index.ts | 3 +- .../client-axios/clean-false/sdk.gen.ts | 106 +- .../client-axios/clean-false/types.gen.ts | 2 +- .../client-axios/default/client.gen.ts | 4 +- .../@hey-api/client-axios/default/index.ts | 3 +- .../@hey-api/client-axios/default/sdk.gen.ts | 106 +- .../client-axios/default/types.gen.ts | 2 +- .../sdk-client-optional/client.gen.ts | 4 +- .../client-axios/sdk-client-optional/index.ts | 3 +- .../sdk-client-optional/sdk.gen.ts | 106 +- .../sdk-client-optional/types.gen.ts | 2 +- .../sdk-client-required/client.gen.ts | 4 +- .../client-axios/sdk-client-required/index.ts | 3 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/client.gen.ts | 4 +- .../tsconfig-nodenext-sdk/index.ts | 3 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 106 +- .../tsconfig-nodenext-sdk/types.gen.ts | 2 +- .../client-fetch/base-url-false/client.gen.ts | 4 +- .../client-fetch/base-url-false/index.ts | 3 +- .../client-fetch/base-url-false/types.gen.ts | 2 +- .../base-url-number/client.gen.ts | 4 +- .../client-fetch/base-url-number/index.ts | 3 +- .../client-fetch/base-url-number/types.gen.ts | 2 +- .../base-url-strict/client.gen.ts | 4 +- .../client-fetch/base-url-strict/index.ts | 3 +- .../client-fetch/base-url-strict/types.gen.ts | 2 +- .../base-url-string/client.gen.ts | 4 +- .../client-fetch/base-url-string/index.ts | 3 +- .../client-fetch/base-url-string/types.gen.ts | 2 +- .../client-fetch/clean-false/client.gen.ts | 4 +- .../client-fetch/clean-false/index.ts | 3 +- .../client-fetch/clean-false/sdk.gen.ts | 106 +- .../client-fetch/clean-false/types.gen.ts | 2 +- .../client-fetch/default/client.gen.ts | 4 +- .../@hey-api/client-fetch/default/index.ts | 3 +- .../@hey-api/client-fetch/default/sdk.gen.ts | 106 +- .../client-fetch/default/types.gen.ts | 2 +- .../sdk-client-optional/client.gen.ts | 4 +- .../client-fetch/sdk-client-optional/index.ts | 3 +- .../sdk-client-optional/sdk.gen.ts | 106 +- .../sdk-client-optional/types.gen.ts | 2 +- .../sdk-client-required/client.gen.ts | 4 +- .../client-fetch/sdk-client-required/index.ts | 3 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/client.gen.ts | 4 +- .../tsconfig-nodenext-sdk/index.ts | 3 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 106 +- .../tsconfig-nodenext-sdk/types.gen.ts | 2 +- .../client-next/base-url-false/client.gen.ts | 4 +- .../client-next/base-url-false/index.ts | 3 +- .../client-next/base-url-false/types.gen.ts | 2 +- .../client-next/base-url-number/client.gen.ts | 4 +- .../client-next/base-url-number/index.ts | 3 +- .../client-next/base-url-number/types.gen.ts | 2 +- .../client-next/base-url-strict/client.gen.ts | 4 +- .../client-next/base-url-strict/index.ts | 3 +- .../client-next/base-url-strict/types.gen.ts | 2 +- .../client-next/base-url-string/client.gen.ts | 4 +- .../client-next/base-url-string/index.ts | 3 +- .../client-next/base-url-string/types.gen.ts | 2 +- .../client-next/clean-false/client.gen.ts | 4 +- .../@hey-api/client-next/clean-false/index.ts | 3 +- .../client-next/clean-false/sdk.gen.ts | 106 +- .../client-next/clean-false/types.gen.ts | 2 +- .../client-next/default/client.gen.ts | 4 +- .../@hey-api/client-next/default/index.ts | 3 +- .../@hey-api/client-next/default/sdk.gen.ts | 106 +- .../@hey-api/client-next/default/types.gen.ts | 2 +- .../sdk-client-optional/client.gen.ts | 4 +- .../client-next/sdk-client-optional/index.ts | 3 +- .../sdk-client-optional/sdk.gen.ts | 106 +- .../sdk-client-optional/types.gen.ts | 2 +- .../sdk-client-required/client.gen.ts | 4 +- .../client-next/sdk-client-required/index.ts | 3 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/client.gen.ts | 4 +- .../tsconfig-nodenext-sdk/index.ts | 3 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 106 +- .../tsconfig-nodenext-sdk/types.gen.ts | 2 +- .../client-nuxt/base-url-false/client.gen.ts | 4 +- .../client-nuxt/base-url-false/index.ts | 3 +- .../client-nuxt/base-url-false/types.gen.ts | 2 +- .../client-nuxt/base-url-number/client.gen.ts | 4 +- .../client-nuxt/base-url-number/index.ts | 3 +- .../client-nuxt/base-url-number/types.gen.ts | 2 +- .../client-nuxt/base-url-strict/client.gen.ts | 4 +- .../client-nuxt/base-url-strict/index.ts | 3 +- .../client-nuxt/base-url-strict/types.gen.ts | 2 +- .../client-nuxt/base-url-string/client.gen.ts | 4 +- .../client-nuxt/base-url-string/index.ts | 3 +- .../client-nuxt/base-url-string/types.gen.ts | 2 +- .../client-nuxt/clean-false/client.gen.ts | 4 +- .../@hey-api/client-nuxt/clean-false/index.ts | 3 +- .../client-nuxt/clean-false/sdk.gen.ts | 106 +- .../client-nuxt/clean-false/types.gen.ts | 2 +- .../client-nuxt/default/client.gen.ts | 4 +- .../@hey-api/client-nuxt/default/index.ts | 3 +- .../@hey-api/client-nuxt/default/sdk.gen.ts | 106 +- .../@hey-api/client-nuxt/default/types.gen.ts | 2 +- .../sdk-client-optional/client.gen.ts | 4 +- .../client-nuxt/sdk-client-optional/index.ts | 3 +- .../sdk-client-optional/sdk.gen.ts | 106 +- .../sdk-client-optional/types.gen.ts | 2 +- .../sdk-client-required/client.gen.ts | 4 +- .../client-nuxt/sdk-client-required/index.ts | 3 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 2 +- .../tsconfig-nodenext-sdk/client.gen.ts | 4 +- .../tsconfig-nodenext-sdk/index.ts | 3 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 106 +- .../tsconfig-nodenext-sdk/types.gen.ts | 2 +- .../base-url-false/client.gen.ts | 4 +- .../client-custom/base-url-false/index.ts | 3 +- .../client-custom/base-url-false/types.gen.ts | 2 +- .../base-url-number/client.gen.ts | 4 +- .../client-custom/base-url-number/index.ts | 3 +- .../base-url-number/types.gen.ts | 2 +- .../base-url-strict/client.gen.ts | 4 +- .../client-custom/base-url-strict/index.ts | 3 +- .../base-url-strict/types.gen.ts | 2 +- .../base-url-string/client.gen.ts | 4 +- .../client-custom/base-url-string/index.ts | 3 +- .../base-url-string/types.gen.ts | 2 +- .../client-custom/bundle/client.gen.ts | 4 +- .../clients/client-custom/bundle/index.ts | 3 +- .../clients/client-custom/bundle/sdk.gen.ts | 106 +- .../clients/client-custom/bundle/types.gen.ts | 2 +- .../client-custom/default/client.gen.ts | 4 +- .../clients/client-custom/default/index.ts | 3 +- .../clients/client-custom/default/sdk.gen.ts | 106 +- .../client-custom/default/types.gen.ts | 2 +- .../sdk-client-optional/client.gen.ts | 4 +- .../sdk-client-optional/index.ts | 3 +- .../sdk-client-optional/sdk.gen.ts | 106 +- .../sdk-client-optional/types.gen.ts | 2 +- .../sdk-client-required/client.gen.ts | 4 +- .../sdk-client-required/index.ts | 3 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 2 +- .../my-client/base-url-false/client.gen.ts | 4 +- .../my-client/base-url-false/client/plugin.ts | 29 +- .../clients/my-client/base-url-false/index.ts | 3 +- .../my-client/base-url-false/types.gen.ts | 2 +- .../my-client/base-url-number/client.gen.ts | 4 +- .../base-url-number/client/plugin.ts | 29 +- .../my-client/base-url-number/index.ts | 3 +- .../my-client/base-url-number/types.gen.ts | 2 +- .../my-client/base-url-strict/client.gen.ts | 4 +- .../base-url-strict/client/plugin.ts | 29 +- .../my-client/base-url-strict/index.ts | 3 +- .../my-client/base-url-strict/types.gen.ts | 2 +- .../my-client/base-url-string/client.gen.ts | 4 +- .../base-url-string/client/plugin.ts | 29 +- .../my-client/base-url-string/index.ts | 3 +- .../my-client/base-url-string/types.gen.ts | 2 +- .../clients/my-client/bundle/client.gen.ts | 4 +- .../clients/my-client/bundle/client/plugin.ts | 29 +- .../3.1.x/clients/my-client/bundle/index.ts | 3 +- .../3.1.x/clients/my-client/bundle/sdk.gen.ts | 106 +- .../clients/my-client/bundle/types.gen.ts | 2 +- .../clients/my-client/default/client.gen.ts | 4 +- .../my-client/default/client/plugin.ts | 29 +- .../3.1.x/clients/my-client/default/index.ts | 3 +- .../clients/my-client/default/sdk.gen.ts | 106 +- .../clients/my-client/default/types.gen.ts | 2 +- .../sdk-client-optional/client.gen.ts | 4 +- .../sdk-client-optional/client/plugin.ts | 29 +- .../my-client/sdk-client-optional/index.ts | 3 +- .../my-client/sdk-client-optional/sdk.gen.ts | 106 +- .../sdk-client-optional/types.gen.ts | 2 +- .../sdk-client-required/client.gen.ts | 4 +- .../sdk-client-required/client/plugin.ts | 29 +- .../my-client/sdk-client-required/index.ts | 3 +- .../my-client/sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 2 +- .../3.1.x/components-request-bodies/index.ts | 3 +- .../components-request-bodies/types.gen.ts | 2 +- .../test/__snapshots__/3.1.x/const/index.ts | 3 +- .../__snapshots__/3.1.x/const/types.gen.ts | 2 +- .../3.1.x/content-binary/index.ts | 3 +- .../3.1.x/content-binary/types.gen.ts | 2 +- .../3.1.x/content-types/client.gen.ts | 4 +- .../3.1.x/content-types/index.ts | 3 +- .../3.1.x/content-types/sdk.gen.ts | 8 +- .../3.1.x/content-types/types.gen.ts | 2 +- .../3.1.x/discriminator-all-of/index.ts | 3 +- .../3.1.x/discriminator-all-of/types.gen.ts | 2 +- .../3.1.x/discriminator-any-of/index.ts | 3 +- .../3.1.x/discriminator-any-of/types.gen.ts | 2 +- .../3.1.x/discriminator-mapped-many/index.ts | 3 +- .../discriminator-mapped-many/types.gen.ts | 2 +- .../3.1.x/discriminator-one-of/index.ts | 3 +- .../3.1.x/discriminator-one-of/types.gen.ts | 2 +- .../3.1.x/duplicate-null/index.ts | 3 +- .../3.1.x/duplicate-null/types.gen.ts | 2 +- .../__snapshots__/3.1.x/enum-escape/index.ts | 3 +- .../3.1.x/enum-escape/types.gen.ts | 2 +- .../3.1.x/enum-inline-javascript/index.ts | 3 +- .../3.1.x/enum-inline-javascript/types.gen.ts | 2 +- .../3.1.x/enum-inline-typescript/index.ts | 3 +- .../3.1.x/enum-inline-typescript/types.gen.ts | 2 +- .../__snapshots__/3.1.x/enum-inline/index.ts | 3 +- .../3.1.x/enum-inline/types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../3.1.x/enum-names-values/index.ts | 3 +- .../3.1.x/enum-names-values/types.gen.ts | 2 +- .../__snapshots__/3.1.x/enum-null/index.ts | 3 +- .../3.1.x/enum-null/types.gen.ts | 2 +- .../3.1.x/enum-null/valibot.gen.ts | 2 +- .../3.1.x/exclude-deprecated/index.ts | 3 +- .../3.1.x/exclude-deprecated/types.gen.ts | 2 +- .../__snapshots__/3.1.x/headers/client.gen.ts | 4 +- .../test/__snapshots__/3.1.x/headers/index.ts | 3 +- .../__snapshots__/3.1.x/headers/sdk.gen.ts | 14 +- .../__snapshots__/3.1.x/headers/types.gen.ts | 2 +- .../3.1.x/integer-formats/valibot.gen.ts | 2 +- .../@tanstack/react-query.gen.ts | 6 +- .../internal-name-conflict/client.gen.ts | 4 +- .../3.1.x/internal-name-conflict/index.ts | 3 +- .../3.1.x/internal-name-conflict/sdk.gen.ts | 12 +- .../3.1.x/internal-name-conflict/types.gen.ts | 2 +- .../3.1.x/negative-property-names/index.ts | 3 +- .../negative-property-names/types.gen.ts | 2 +- .../3.1.x/object-properties-all-of/index.ts | 3 +- .../object-properties-all-of/types.gen.ts | 2 +- .../3.1.x/object-properties-any-of/index.ts | 3 +- .../object-properties-any-of/types.gen.ts | 2 +- .../3.1.x/object-properties-one-of/index.ts | 3 +- .../object-properties-one-of/types.gen.ts | 2 +- .../3.1.x/object-property-names/index.ts | 3 +- .../3.1.x/object-property-names/types.gen.ts | 2 +- .../3.1.x/operation-204/index.ts | 3 +- .../3.1.x/operation-204/types.gen.ts | 2 +- .../@tanstack/react-query.gen.ts | 6 +- .../3.1.x/pagination-ref/client.gen.ts | 4 +- .../3.1.x/pagination-ref/index.ts | 3 +- .../3.1.x/pagination-ref/sdk.gen.ts | 10 +- .../3.1.x/pagination-ref/types.gen.ts | 2 +- .../client.gen.ts | 4 +- .../parameter-explode-false-axios/index.ts | 3 +- .../parameter-explode-false-axios/sdk.gen.ts | 8 +- .../types.gen.ts | 2 +- .../parameter-explode-false/client.gen.ts | 4 +- .../3.1.x/parameter-explode-false/index.ts | 3 +- .../3.1.x/parameter-explode-false/sdk.gen.ts | 8 +- .../parameter-explode-false/types.gen.ts | 2 +- .../3.1.x/parameter-tuple/index.ts | 3 +- .../3.1.x/parameter-tuple/types.gen.ts | 2 +- .../3.1.x/pattern-properties/index.ts | 3 +- .../3.1.x/pattern-properties/types.gen.ts | 2 +- .../sdk-nested-classes-instance/client.gen.ts | 4 +- .../sdk-nested-classes-instance/index.ts | 3 +- .../sdk-nested-classes-instance/sdk.gen.ts | 8 +- .../sdk-nested-classes-instance/types.gen.ts | 2 +- .../sdk-nested-classes/client.gen.ts | 4 +- .../client-fetch/sdk-nested-classes/index.ts | 3 +- .../sdk-nested-classes/sdk.gen.ts | 16 +- .../sdk-nested-classes/types.gen.ts | 2 +- .../@hey-api/schemas/default/schemas.gen.ts | 2 +- .../@hey-api/sdk/default/client.gen.ts | 4 +- .../plugins/@hey-api/sdk/default/index.ts | 3 +- .../plugins/@hey-api/sdk/default/sdk.gen.ts | 106 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 2 +- .../@hey-api/sdk/instance/client.gen.ts | 4 +- .../plugins/@hey-api/sdk/instance/index.ts | 3 +- .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 8 +- .../@hey-api/sdk/instance/types.gen.ts | 2 +- .../@hey-api/sdk/throwOnError/client.gen.ts | 4 +- .../@hey-api/sdk/throwOnError/index.ts | 3 +- .../@hey-api/sdk/throwOnError/sdk.gen.ts | 106 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 2 +- .../type-format-valibot/client.gen.ts | 4 +- .../transformers/type-format-valibot/index.ts | 3 +- .../type-format-valibot/sdk.gen.ts | 15 +- .../type-format-valibot/transformers.gen.ts | 2 +- .../type-format-valibot/types.gen.ts | 2 +- .../type-format-valibot/valibot.gen.ts | 2 +- .../type-format-zod/client.gen.ts | 4 +- .../transformers/type-format-zod/index.ts | 3 +- .../transformers/type-format-zod/sdk.gen.ts | 8 +- .../type-format-zod/transformers.gen.ts | 2 +- .../transformers/type-format-zod/types.gen.ts | 2 +- .../transformers/type-format-zod/zod.gen.ts | 2 +- .../client.gen.ts | 4 +- .../index.ts | 3 +- .../types.gen.ts | 2 +- .../client.gen.ts | 4 +- .../transforms-read-write-ignore/index.ts | 3 +- .../transforms-read-write-ignore/types.gen.ts | 2 +- .../@pinia/colada/fetch/@pinia/colada.gen.ts | 10 +- .../plugins/@pinia/colada/fetch/client.gen.ts | 4 +- .../plugins/@pinia/colada/fetch/index.ts | 3 +- .../plugins/@pinia/colada/fetch/sdk.gen.ts | 106 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 2 +- .../@pinia/colada/CollectionFormat.gen.ts | 56 - .../group-by-tag/@pinia/colada/Complex.gen.ts | 69 - .../@pinia/colada/Defaults.gen.ts | 82 - .../@pinia/colada/Deprecated.gen.ts | 21 - .../@pinia/colada/Descriptions.gen.ts | 18 - .../@pinia/colada/Duplicate.gen.ts | 95 - .../group-by-tag/@pinia/colada/Error.gen.ts | 18 - .../@pinia/colada/FileResponse.gen.ts | 56 - .../@pinia/colada/FormData.gen.ts | 18 - .../group-by-tag/@pinia/colada/Header.gen.ts | 18 - .../@pinia/colada/MultipleTags1.gen.ts | 72 - ...05\303\266\303\264\303\252\303\212.gen.ts" | 34 - .../@pinia/colada/Parameters.gen.ts | 108 - .../@pinia/colada/RequestBody.gen.ts | 18 - .../@pinia/colada/Response.gen.ts | 98 - .../group-by-tag/@pinia/colada/Simple.gen.ts | 124 - .../group-by-tag/@pinia/colada/Types.gen.ts | 56 - .../group-by-tag/@pinia/colada/Upload.gen.ts | 18 - .../group-by-tag/@pinia/colada/default.gen.ts | 111 - .../@pinia/colada/multipart.gen.ts | 69 - .../@pinia/colada/noContent.gen.ts | 56 - .../@pinia/colada/group-by-tag/client.gen.ts | 18 - .../colada/group-by-tag/client/client.gen.ts | 267 --- .../colada/group-by-tag/client/index.ts | 25 - .../colada/group-by-tag/client/types.gen.ts | 268 --- .../colada/group-by-tag/client/utils.gen.ts | 327 --- .../colada/group-by-tag/core/auth.gen.ts | 42 - .../group-by-tag/core/bodySerializer.gen.ts | 92 - .../colada/group-by-tag/core/params.gen.ts | 153 -- .../group-by-tag/core/pathSerializer.gen.ts | 181 -- .../group-by-tag/core/serverSentEvents.gen.ts | 264 --- .../colada/group-by-tag/core/types.gen.ts | 118 - .../colada/group-by-tag/core/utils.gen.ts | 114 - .../@pinia/colada/group-by-tag/index.ts | 3 - .../@pinia/colada/group-by-tag/sdk.gen.ts | 409 ---- .../@pinia/colada/group-by-tag/types.gen.ts | 2063 ----------------- .../angular-query-experimental.gen.ts | 8 +- .../asClass/client.gen.ts | 4 +- .../asClass/index.ts | 3 +- .../asClass/sdk.gen.ts | 18 +- .../asClass/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 12 +- .../axios/client.gen.ts | 4 +- .../angular-query-experimental/axios/index.ts | 3 +- .../axios/sdk.gen.ts | 106 +- .../axios/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 12 +- .../fetch/client.gen.ts | 4 +- .../angular-query-experimental/fetch/index.ts | 3 +- .../fetch/sdk.gen.ts | 106 +- .../fetch/types.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 6 +- .../name-builder/client.gen.ts | 4 +- .../name-builder/index.ts | 3 +- .../name-builder/sdk.gen.ts | 18 +- .../name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/react-query.gen.ts | 8 +- .../react-query/asClass/client.gen.ts | 4 +- .../@tanstack/react-query/asClass/index.ts | 3 +- .../@tanstack/react-query/asClass/sdk.gen.ts | 18 +- .../react-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/react-query.gen.ts | 12 +- .../@tanstack/react-query/axios/client.gen.ts | 4 +- .../@tanstack/react-query/axios/index.ts | 3 +- .../@tanstack/react-query/axios/sdk.gen.ts | 106 +- .../@tanstack/react-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/react-query.gen.ts | 12 +- .../@tanstack/react-query/fetch/client.gen.ts | 4 +- .../@tanstack/react-query/fetch/index.ts | 3 +- .../@tanstack/react-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/react-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/react-query.gen.ts | 6 +- .../react-query/name-builder/client.gen.ts | 4 +- .../react-query/name-builder/index.ts | 3 +- .../react-query/name-builder/sdk.gen.ts | 18 +- .../react-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/solid-query.gen.ts | 8 +- .../solid-query/asClass/client.gen.ts | 4 +- .../@tanstack/solid-query/asClass/index.ts | 3 +- .../@tanstack/solid-query/asClass/sdk.gen.ts | 18 +- .../solid-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/solid-query.gen.ts | 12 +- .../@tanstack/solid-query/axios/client.gen.ts | 4 +- .../@tanstack/solid-query/axios/index.ts | 3 +- .../@tanstack/solid-query/axios/sdk.gen.ts | 106 +- .../@tanstack/solid-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/solid-query.gen.ts | 12 +- .../@tanstack/solid-query/fetch/client.gen.ts | 4 +- .../@tanstack/solid-query/fetch/index.ts | 3 +- .../@tanstack/solid-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/solid-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/solid-query.gen.ts | 6 +- .../solid-query/name-builder/client.gen.ts | 4 +- .../solid-query/name-builder/index.ts | 3 +- .../solid-query/name-builder/sdk.gen.ts | 18 +- .../solid-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/svelte-query.gen.ts | 8 +- .../svelte-query/asClass/client.gen.ts | 4 +- .../@tanstack/svelte-query/asClass/index.ts | 3 +- .../@tanstack/svelte-query/asClass/sdk.gen.ts | 18 +- .../svelte-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/svelte-query.gen.ts | 12 +- .../svelte-query/axios/client.gen.ts | 4 +- .../@tanstack/svelte-query/axios/index.ts | 3 +- .../@tanstack/svelte-query/axios/sdk.gen.ts | 106 +- .../@tanstack/svelte-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/svelte-query.gen.ts | 12 +- .../svelte-query/fetch/client.gen.ts | 4 +- .../@tanstack/svelte-query/fetch/index.ts | 3 +- .../@tanstack/svelte-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 2 +- .../@tanstack/svelte-query.gen.ts | 6 +- .../svelte-query/name-builder/client.gen.ts | 4 +- .../svelte-query/name-builder/index.ts | 3 +- .../svelte-query/name-builder/sdk.gen.ts | 18 +- .../svelte-query/name-builder/types.gen.ts | 2 +- .../asClass/@tanstack/vue-query.gen.ts | 8 +- .../@tanstack/vue-query/asClass/client.gen.ts | 4 +- .../@tanstack/vue-query/asClass/index.ts | 3 +- .../@tanstack/vue-query/asClass/sdk.gen.ts | 18 +- .../@tanstack/vue-query/asClass/types.gen.ts | 2 +- .../axios/@tanstack/vue-query.gen.ts | 12 +- .../@tanstack/vue-query/axios/client.gen.ts | 4 +- .../@tanstack/vue-query/axios/index.ts | 3 +- .../@tanstack/vue-query/axios/sdk.gen.ts | 106 +- .../@tanstack/vue-query/axios/types.gen.ts | 2 +- .../fetch/@tanstack/vue-query.gen.ts | 12 +- .../@tanstack/vue-query/fetch/client.gen.ts | 4 +- .../@tanstack/vue-query/fetch/index.ts | 3 +- .../@tanstack/vue-query/fetch/sdk.gen.ts | 106 +- .../@tanstack/vue-query/fetch/types.gen.ts | 2 +- .../name-builder/@tanstack/vue-query.gen.ts | 6 +- .../vue-query/name-builder/client.gen.ts | 4 +- .../@tanstack/vue-query/name-builder/index.ts | 3 +- .../vue-query/name-builder/sdk.gen.ts | 18 +- .../vue-query/name-builder/types.gen.ts | 2 +- .../plugins/fastify/default/fastify.gen.ts | 8 +- .../3.1.x/plugins/fastify/default/index.ts | 3 +- .../plugins/fastify/default/types.gen.ts | 2 +- .../plugins/valibot/default/valibot.gen.ts | 2 +- .../__snapshots__/3.1.x/ref-type/index.ts | 3 +- .../__snapshots__/3.1.x/ref-type/types.gen.ts | 2 +- .../3.1.x/required-all-of-ref/index.ts | 3 +- .../3.1.x/required-all-of-ref/types.gen.ts | 2 +- .../3.1.x/required-any-of-ref/index.ts | 3 +- .../3.1.x/required-any-of-ref/types.gen.ts | 2 +- .../3.1.x/required-one-of-ref/index.ts | 3 +- .../3.1.x/required-one-of-ref/types.gen.ts | 2 +- .../__snapshots__/3.1.x/schema-const/index.ts | 3 +- .../3.1.x/schema-const/types.gen.ts | 2 +- .../3.1.x/schema-const/valibot.gen.ts | 2 +- .../3.1.x/security-api-key/client.gen.ts | 4 +- .../3.1.x/security-api-key/index.ts | 3 +- .../3.1.x/security-api-key/sdk.gen.ts | 10 +- .../3.1.x/security-api-key/types.gen.ts | 2 +- .../3.1.x/security-false/client.gen.ts | 4 +- .../3.1.x/security-false/index.ts | 3 +- .../3.1.x/security-false/sdk.gen.ts | 8 +- .../3.1.x/security-false/types.gen.ts | 2 +- .../3.1.x/security-http-bearer/client.gen.ts | 4 +- .../3.1.x/security-http-bearer/index.ts | 3 +- .../3.1.x/security-http-bearer/sdk.gen.ts | 8 +- .../3.1.x/security-http-bearer/types.gen.ts | 2 +- .../3.1.x/security-oauth2/client.gen.ts | 4 +- .../3.1.x/security-oauth2/index.ts | 3 +- .../3.1.x/security-oauth2/sdk.gen.ts | 8 +- .../3.1.x/security-oauth2/types.gen.ts | 2 +- .../security-open-id-connect/client.gen.ts | 4 +- .../3.1.x/security-open-id-connect/index.ts | 3 +- .../3.1.x/security-open-id-connect/sdk.gen.ts | 8 +- .../security-open-id-connect/types.gen.ts | 2 +- .../__snapshots__/3.1.x/servers/client.gen.ts | 4 +- .../test/__snapshots__/3.1.x/servers/index.ts | 3 +- .../__snapshots__/3.1.x/servers/types.gen.ts | 2 +- .../3.1.x/sse-angular/client.gen.ts | 4 +- .../__snapshots__/3.1.x/sse-angular/index.ts | 3 +- .../3.1.x/sse-angular/sdk.gen.ts | 8 +- .../3.1.x/sse-angular/types.gen.ts | 2 +- .../3.1.x/sse-axios/client.gen.ts | 4 +- .../__snapshots__/3.1.x/sse-axios/index.ts | 3 +- .../__snapshots__/3.1.x/sse-axios/sdk.gen.ts | 8 +- .../3.1.x/sse-axios/types.gen.ts | 2 +- .../3.1.x/sse-fetch/client.gen.ts | 4 +- .../__snapshots__/3.1.x/sse-fetch/index.ts | 3 +- .../__snapshots__/3.1.x/sse-fetch/sdk.gen.ts | 8 +- .../3.1.x/sse-fetch/types.gen.ts | 2 +- .../3.1.x/sse-next/client.gen.ts | 4 +- .../__snapshots__/3.1.x/sse-next/index.ts | 3 +- .../__snapshots__/3.1.x/sse-next/sdk.gen.ts | 8 +- .../__snapshots__/3.1.x/sse-next/types.gen.ts | 2 +- .../3.1.x/sse-nuxt/client.gen.ts | 4 +- .../__snapshots__/3.1.x/sse-nuxt/index.ts | 3 +- .../__snapshots__/3.1.x/sse-nuxt/sdk.gen.ts | 8 +- .../__snapshots__/3.1.x/sse-nuxt/types.gen.ts | 2 +- .../3.1.x/transformers-all-of/client.gen.ts | 4 +- .../3.1.x/transformers-all-of/index.ts | 3 +- .../transformers-all-of/transformers.gen.ts | 2 +- .../3.1.x/transformers-all-of/types.gen.ts | 2 +- .../transformers-any-of-null/client.gen.ts | 4 +- .../3.1.x/transformers-any-of-null/index.ts | 3 +- .../transformers.gen.ts | 2 +- .../transformers-any-of-null/types.gen.ts | 2 +- .../3.1.x/transformers-array/client.gen.ts | 4 +- .../3.1.x/transformers-array/index.ts | 3 +- .../transformers-array/transformers.gen.ts | 2 +- .../3.1.x/transformers-array/types.gen.ts | 2 +- .../3.1.x/transforms-read-write/client.gen.ts | 4 +- .../3.1.x/transforms-read-write/index.ts | 3 +- .../3.1.x/transforms-read-write/types.gen.ts | 2 +- .../__snapshots__/3.1.x/type-invalid/index.ts | 3 +- .../3.1.x/type-invalid/types.gen.ts | 2 +- .../__snapshots__/3.1.x/union-types/index.ts | 3 +- .../3.1.x/union-types/types.gen.ts | 2 +- .../validators-bigint-min-max/valibot.gen.ts | 2 +- .../validators-circular-ref-2/valibot.gen.ts | 2 +- .../validators-circular-ref/valibot.gen.ts | 2 +- .../3.1.x/validators-metadata/valibot.gen.ts | 2 +- .../3.1.x/validators-types/valibot.gen.ts | 2 +- .../validators-union-merge/valibot.gen.ts | 2 +- .../3.1.x/validators/valibot.gen.ts | 2 +- .../__snapshots__/3.1.x/webhooks/index.ts | 3 +- .../__snapshots__/3.1.x/webhooks/types.gen.ts | 2 +- .../3.1.x/webhooks/valibot.gen.ts | 2 +- .../__snapshots__/3.1.x/webhooks/zod.gen.ts | 2 +- .../angular-query-experimental.gen.ts | 6 +- .../meta/@tanstack/react-query.gen.ts | 6 +- .../meta/@tanstack/solid-query.gen.ts | 6 +- .../meta/@tanstack/svelte-query.gen.ts | 6 +- .../@tanstack/meta/@tanstack/vue-query.gen.ts | 6 +- .../plugins/@tanstack/meta/client.gen.ts | 4 +- .../plugins/@tanstack/meta/index.ts | 3 +- .../plugins/@tanstack/meta/sdk.gen.ts | 10 +- .../plugins/@tanstack/meta/types.gen.ts | 2 +- .../v3-schemas-form/schemas.gen.ts.snap | 2 +- .../v3-schemas-json/schemas.gen.ts.snap | 2 +- .../v3-schemas-name/schemas.gen.ts.snap | 2 +- .../v3-types-PascalCase/index.ts.snap | 3 +- .../v3-types-PascalCase/types.gen.ts.snap | 2 +- .../generated/v3_no_index/client.gen.ts.snap | 4 +- .../generated/v3_no_index/types.gen.ts.snap | 2 +- .../test/generated/v3_types/index.ts.snap | 3 +- .../test/generated/v3_types/types.gen.ts.snap | 2 +- .../generated/v3_types_no_tree/index.ts.snap | 3 +- .../v3_types_no_tree/types.gen.ts.snap | 2 +- .../main/test/custom/client/plugin.ts | 30 +- .../main/test/openapi-ts.config.ts | 70 +- .../main/test/plugins.test.ts | 14 - .../src/generate/__tests__/file.test.ts | 35 + packages/openapi-ts/src/generate/client.ts | 12 - packages/openapi-ts/src/generate/file.ts | 275 +++ .../src/generate/file/__tests__/file.test.ts | 380 --- .../openapi-ts/src/generate/file/index.ts | 635 ----- .../openapi-ts/src/generate/file/types.d.ts | 91 - packages/openapi-ts/src/generate/renderer.ts | 208 +- packages/openapi-ts/src/ir/context.ts | 1 - packages/openapi-ts/src/ir/types.d.ts | 5 - .../src/plugins/@angular/common/api.ts | 36 + .../src/plugins/@angular/common/config.ts | 4 + .../src/plugins/@angular/common/constants.ts | 2 - .../plugins/@angular/common/httpRequests.ts | 252 +- .../plugins/@angular/common/httpResources.ts | 282 ++- .../src/plugins/@angular/common/types.d.ts | 3 +- .../plugins/@hey-api/client-angular/api.ts | 25 + .../plugins/@hey-api/client-angular/config.ts | 6 +- .../@hey-api/client-angular/types.d.ts | 7 +- .../src/plugins/@hey-api/client-axios/api.ts | 25 + .../plugins/@hey-api/client-axios/config.ts | 6 +- .../plugins/@hey-api/client-axios/types.d.ts | 7 +- .../plugins/@hey-api/client-core/client.ts | 85 +- .../client-core/createClientConfig.ts | 58 +- .../plugins/@hey-api/client-core/plugin.ts | 22 +- .../plugins/@hey-api/client-core/types.d.ts | 13 +- .../src/plugins/@hey-api/client-core/utils.ts | 2 - .../src/plugins/@hey-api/client-fetch/api.ts | 25 + .../plugins/@hey-api/client-fetch/config.ts | 6 +- .../plugins/@hey-api/client-fetch/types.d.ts | 7 +- .../src/plugins/@hey-api/client-next/api.ts | 25 + .../plugins/@hey-api/client-next/config.ts | 6 +- .../plugins/@hey-api/client-next/types.d.ts | 3 +- .../src/plugins/@hey-api/client-nuxt/api.ts | 25 + .../plugins/@hey-api/client-nuxt/config.ts | 6 +- .../plugins/@hey-api/client-nuxt/types.d.ts | 3 +- .../src/plugins/@hey-api/schemas/api.ts | 25 + .../src/plugins/@hey-api/schemas/config.ts | 4 + .../src/plugins/@hey-api/schemas/plugin.ts | 37 +- .../src/plugins/@hey-api/schemas/types.d.ts | 3 +- .../src/plugins/@hey-api/sdk/api.ts | 38 + .../src/plugins/@hey-api/sdk/config.ts | 4 + .../src/plugins/@hey-api/sdk/constants.ts | 2 - .../src/plugins/@hey-api/sdk/operation.ts | 266 +-- .../src/plugins/@hey-api/sdk/plugin-legacy.ts | 7 +- .../src/plugins/@hey-api/sdk/plugin.ts | 230 +- .../src/plugins/@hey-api/sdk/typeOptions.ts | 50 +- .../src/plugins/@hey-api/sdk/types.d.ts | 3 +- .../src/plugins/@hey-api/sdk/validator.ts | 58 +- .../src/plugins/@hey-api/transformers/api.ts | 26 + .../plugins/@hey-api/transformers/config.ts | 26 + .../@hey-api/transformers/expressions.ts | 4 +- .../plugins/@hey-api/transformers/plugin.ts | 225 +- .../plugins/@hey-api/transformers/types.d.ts | 44 +- .../src/plugins/@hey-api/typescript/api.ts | 96 +- .../@hey-api/typescript/clientOptions.ts | 15 +- .../src/plugins/@hey-api/typescript/config.ts | 6 +- .../src/plugins/@hey-api/typescript/export.ts | 164 ++ .../plugins/@hey-api/typescript/operation.ts | 155 +- .../src/plugins/@hey-api/typescript/plugin.ts | 373 +-- .../src/plugins/@hey-api/typescript/ref.ts | 1 - .../plugins/@hey-api/typescript/types.d.ts | 4 +- .../plugins/@hey-api/typescript/webhook.ts | 101 +- .../plugins/@hey-api/typescript/webhooks.ts | 23 +- .../@pinia/colada/__tests__/plugin.test.ts | 105 - .../src/plugins/@pinia/colada/api.ts | 38 + .../src/plugins/@pinia/colada/config.ts | 5 +- .../plugins/@pinia/colada/mutationOptions.ts | 62 +- .../src/plugins/@pinia/colada/plugin.ts | 138 +- .../src/plugins/@pinia/colada/queryKey.ts | 470 ++-- .../src/plugins/@pinia/colada/queryOptions.ts | 89 +- .../src/plugins/@pinia/colada/state.ts | 7 - .../src/plugins/@pinia/colada/types.d.ts | 19 +- .../src/plugins/@pinia/colada/useType.ts | 80 + .../src/plugins/@pinia/colada/utils.ts | 130 -- .../angular-query-experimental/api.ts | 48 + .../angular-query-experimental/config.ts | 4 + .../angular-query-experimental/types.d.ts | 3 +- .../query-core/infiniteQueryOptions.ts | 123 +- .../@tanstack/query-core/mutationOptions.ts | 44 +- .../@tanstack/query-core/plugin-legacy.ts | 17 +- .../plugins/@tanstack/query-core/plugin.ts | 75 +- .../plugins/@tanstack/query-core/queryKey.ts | 472 ++-- .../@tanstack/query-core/queryOptions.ts | 64 +- .../plugins/@tanstack/query-core/types.d.ts | 13 +- .../plugins/@tanstack/query-core/useQuery.ts | 52 +- .../plugins/@tanstack/query-core/useType.ts | 103 +- .../src/plugins/@tanstack/react-query/api.ts | 46 + .../plugins/@tanstack/react-query/config.ts | 4 + .../plugins/@tanstack/react-query/types.d.ts | 3 +- .../src/plugins/@tanstack/solid-query/api.ts | 46 + .../plugins/@tanstack/solid-query/config.ts | 4 + .../plugins/@tanstack/solid-query/types.d.ts | 3 +- .../src/plugins/@tanstack/svelte-query/api.ts | 46 + .../plugins/@tanstack/svelte-query/config.ts | 4 + .../plugins/@tanstack/svelte-query/types.d.ts | 3 +- .../src/plugins/@tanstack/vue-query/api.ts | 46 + .../src/plugins/@tanstack/vue-query/config.ts | 4 + .../plugins/@tanstack/vue-query/types.d.ts | 3 +- .../openapi-ts/src/plugins/fastify/api.ts | 25 + .../openapi-ts/src/plugins/fastify/config.ts | 4 + .../openapi-ts/src/plugins/fastify/plugin.ts | 185 +- .../openapi-ts/src/plugins/fastify/types.d.ts | 3 +- .../src/plugins/shared/utils/instance.ts | 16 + .../openapi-ts/src/plugins/valibot/api.ts | 274 +-- .../openapi-ts/src/plugins/valibot/config.ts | 6 +- .../src/plugins/valibot/constants.ts | 3 - .../src/plugins/valibot/operation.ts | 36 +- .../openapi-ts/src/plugins/valibot/plugin.ts | 421 ++-- .../openapi-ts/src/plugins/valibot/types.d.ts | 4 +- .../openapi-ts/src/plugins/valibot/webhook.ts | 19 +- packages/openapi-ts/src/plugins/zod/api.ts | 247 +- packages/openapi-ts/src/plugins/zod/config.ts | 6 +- .../openapi-ts/src/plugins/zod/constants.ts | 3 - packages/openapi-ts/src/plugins/zod/export.ts | 41 +- .../openapi-ts/src/plugins/zod/mini/plugin.ts | 396 ++-- .../src/plugins/zod/shared/operation.ts | 82 +- .../src/plugins/zod/shared/webhook.ts | 44 +- .../openapi-ts/src/plugins/zod/types.d.ts | 4 +- .../openapi-ts/src/plugins/zod/v3/plugin.ts | 343 ++- .../openapi-ts/src/plugins/zod/v4/plugin.ts | 285 ++- pnpm-lock.yaml | 6 + 1308 files changed, 10997 insertions(+), 25068 deletions(-) create mode 100644 packages/codegen-core/src/__tests__/file.ts create mode 100644 packages/codegen-core/src/__tests__/renderer.test.ts create mode 100644 packages/codegen-core/src/bimap/bimap.ts create mode 100644 packages/codegen-core/src/bimap/types.d.ts create mode 100644 packages/codegen-core/src/renderers/renderer.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts delete mode 100644 "packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/index.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts delete mode 100644 "packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/index.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts delete mode 100644 "packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/noContent.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/index.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/index.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/types.gen.ts create mode 100644 packages/openapi-ts/src/generate/__tests__/file.test.ts create mode 100644 packages/openapi-ts/src/generate/file.ts delete mode 100644 packages/openapi-ts/src/generate/file/__tests__/file.test.ts delete mode 100644 packages/openapi-ts/src/generate/file/index.ts delete mode 100644 packages/openapi-ts/src/generate/file/types.d.ts create mode 100644 packages/openapi-ts/src/plugins/@angular/common/api.ts delete mode 100644 packages/openapi-ts/src/plugins/@angular/common/constants.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/transformers/api.ts create mode 100644 packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts delete mode 100644 packages/openapi-ts/src/plugins/@hey-api/typescript/ref.ts delete mode 100644 packages/openapi-ts/src/plugins/@pinia/colada/__tests__/plugin.test.ts create mode 100644 packages/openapi-ts/src/plugins/@pinia/colada/api.ts create mode 100644 packages/openapi-ts/src/plugins/@pinia/colada/useType.ts delete mode 100644 packages/openapi-ts/src/plugins/@pinia/colada/utils.ts create mode 100644 packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/api.ts create mode 100644 packages/openapi-ts/src/plugins/@tanstack/react-query/api.ts create mode 100644 packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts create mode 100644 packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts create mode 100644 packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts create mode 100644 packages/openapi-ts/src/plugins/fastify/api.ts diff --git a/packages/codegen-core/src/__tests__/file.test.ts b/packages/codegen-core/src/__tests__/file.test.ts index bb2d1b1d7..8ad3adb67 100644 --- a/packages/codegen-core/src/__tests__/file.test.ts +++ b/packages/codegen-core/src/__tests__/file.test.ts @@ -2,13 +2,16 @@ import { beforeEach, describe, expect, it } from 'vitest'; import { CodegenFile } from '../files/file'; import type { ICodegenImport } from '../imports/types'; -import type { ICodegenSymbol } from '../symbols/types'; +import { CodegenProject } from '../project/project'; +import type { ICodegenSymbolIn } from '../symbols/types'; describe('CodegenFile', () => { let file: CodegenFile; + let project: CodegenProject; beforeEach(() => { - file = new CodegenFile('a.ts'); + project = new CodegenProject(); + file = new CodegenFile('a.ts', project); }); it('initializes with empty imports and symbols', () => { @@ -58,7 +61,7 @@ describe('CodegenFile', () => { B: 'AliasB', }, from: 'a', - names: ['A', 'B'], + names: ['A', 'AType', 'B'], typeNames: ['AType'], }); }); @@ -105,41 +108,48 @@ describe('CodegenFile', () => { B: 'AliasB', }, from: 'a', - names: ['A', 'B'], + names: ['A', 'AType', 'B'], typeNames: ['AType'], }); }); it('adds symbols', () => { - const sym1: ICodegenSymbol = { name: 'a' }; - const sym2: ICodegenSymbol = { name: 'b' }; + const sym1: ICodegenSymbolIn = { name: 'a', value: 'a' }; + const sym2: ICodegenSymbolIn = { name: 'b', value: 'b' }; + const sym3: ICodegenSymbolIn = { headless: true, name: 'c' }; file.addSymbol(sym1); file.addSymbol(sym2); + file.addSymbol(sym3); expect(file.symbols.length).toBe(2); + expect(file.symbols[0]).not.toBeUndefined(); expect(file.symbols[0]).not.toBe(sym1); - expect(file.symbols[0]).toEqual(sym1); + expect(file.symbols[0]).toMatchObject(sym1); + expect(file.symbols[1]).not.toBeUndefined(); expect(file.symbols[1]).not.toBe(sym2); - expect(file.symbols[1]).toEqual(sym2); + expect(file.symbols[1]).toMatchObject(sym2); }); - it('merges duplicate symbols', () => { - const sym1: ICodegenSymbol = { + it('updates symbols', () => { + const sym1: ICodegenSymbolIn = { + headless: true, name: 'a', value: 1, }; - const sym2: ICodegenSymbol = { - name: 'a', + const inserted = file.addSymbol(sym1); + expect(file.symbols.length).toBe(0); + + const sym2: ICodegenSymbolIn = { + headless: false, + name: 'b', value: 'foo', }; - - file.addSymbol(sym1); - file.addSymbol(sym2); + inserted.update(sym2); expect(file.symbols.length).toBe(1); - expect(file.symbols[0]).toEqual({ - name: 'a', + expect(file.symbols[0]).toMatchObject({ + name: 'b', value: 'foo', }); }); @@ -162,9 +172,9 @@ describe('CodegenFile', () => { }); it('hasSymbol returns true if symbol exists', () => { - file.addSymbol({ name: 'Exists', value: {} }); - expect(file.hasSymbol('Exists')).toBe(true); - expect(file.hasSymbol('Missing')).toBe(false); + const symbol = file.addSymbol({ name: 'Exists', value: {} }); + expect(file.hasSymbol(symbol.id)).toBe(true); + expect(file.hasSymbol(-1)).toBe(false); }); it('imports, exports, and symbols getters cache arrays and update after add', () => { @@ -182,7 +192,8 @@ describe('CodegenFile', () => { expect(file.imports).toEqual([imp]); file.addSymbol(symbol); - expect(file.symbols).toEqual([symbol]); + expect(file.symbols.length).toBe(1); + expect(file.symbols[0]).toMatchObject(symbol); }); it('returns relative path to another files', () => { diff --git a/packages/codegen-core/src/__tests__/file.ts b/packages/codegen-core/src/__tests__/file.ts new file mode 100644 index 000000000..22240de86 --- /dev/null +++ b/packages/codegen-core/src/__tests__/file.ts @@ -0,0 +1,11 @@ +/* @ts-nocheck */ + +/** + * something about _heyapi_1_. Did you know that __heyapi_1__? + */ +export class _heyapi_1_ { + // _heyapi_1_ is great! + _heyapi_2_(_heyapi_12_: ReturnType<_heyapi_4_>): _heyapi_5_ { + return _heyapi_12_; + } +} diff --git a/packages/codegen-core/src/__tests__/project.test.ts b/packages/codegen-core/src/__tests__/project.test.ts index 588bad69a..a8fc02f60 100644 --- a/packages/codegen-core/src/__tests__/project.test.ts +++ b/packages/codegen-core/src/__tests__/project.test.ts @@ -2,7 +2,6 @@ import { beforeEach, describe, expect, it } from 'vitest'; import { CodegenFile } from '../files/file'; import type { ICodegenMeta } from '../meta/types'; -import type { ICodegenOutput } from '../output/types'; import { CodegenProject } from '../project/project'; import type { ICodegenRenderer } from '../renderers/types'; @@ -31,10 +30,10 @@ describe('CodegenProject', () => { expect(project.getFileByPath('b.ts')).toBe(newFile2); }); - it('addExportToFile creates file if missing and adds export', () => { + it('addExport creates file if missing and adds export', () => { const imp = { from: 'lib', names: ['Foo'] }; - project.addExportToFile('a.ts', imp); + project.addExport('a.ts', imp); const file = project.getFileByPath('a.ts')!; expect(file).toBeDefined(); @@ -42,10 +41,10 @@ describe('CodegenProject', () => { expect(file.exports[0]).toEqual(imp); }); - it('addImportToFile creates file if missing and adds import', () => { + it('addImport creates file if missing and adds import', () => { const imp = { from: 'lib', names: ['Foo'] }; - project.addImportToFile('a.ts', imp); + project.addImport('a.ts', imp); const file = project.getFileByPath('a.ts')!; expect(file).toBeDefined(); @@ -53,15 +52,15 @@ describe('CodegenProject', () => { expect(file.imports[0]).toEqual(imp); }); - it('addSymbolToFile creates file if missing and adds symbol', () => { + it('addSymbol creates file if missing and adds symbol', () => { const symbol = { name: 'MySymbol', value: {} }; - project.addSymbolToFile('a.ts', symbol); + project.addSymbol('a.ts', symbol); const file = project.getFileByPath('a.ts')!; expect(file).toBeDefined(); expect(file.symbols.length).toBe(1); - expect(file.symbols[0]).toEqual(symbol); + expect(file.symbols[0]).toMatchObject(symbol); }); it('getAllSymbols returns all symbols from all files', () => { @@ -87,19 +86,20 @@ describe('CodegenProject', () => { // @ts-expect-error // mutate returned array should not affect internal state - files.push(new CodegenFile('b.ts')); + files.push(new CodegenFile('b.ts', project)); expect(project.files).toEqual([file]); }); it('render returns output from all files', () => { class Renderer implements ICodegenRenderer { id = 'foo'; - render(file: CodegenFile, meta?: ICodegenMeta): ICodegenOutput { - return { - content: `content ${file.path}`, - meta: { ...meta }, - path: file.path, - }; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + renderHeader(_file: CodegenFile, _meta?: ICodegenMeta): string { + return ''; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + renderSymbols(file: CodegenFile, _meta?: ICodegenMeta): string { + return `content ${file.path}`; } } const renderer = new Renderer(); @@ -109,8 +109,8 @@ describe('CodegenProject', () => { const outputs = project.render(meta); expect(outputs).toEqual([ - { content: 'content a.ts', meta: { foo: 42 }, path: 'a.ts' }, - { content: 'content b.ts', meta: { foo: 42 }, path: 'b.ts' }, + { content: 'content a.ts', meta: { renderer: 'foo' }, path: 'a.ts' }, + { content: 'content b.ts', meta: { renderer: 'foo' }, path: 'b.ts' }, ]); }); diff --git a/packages/codegen-core/src/__tests__/renderer.test.ts b/packages/codegen-core/src/__tests__/renderer.test.ts new file mode 100644 index 000000000..df7b12226 --- /dev/null +++ b/packages/codegen-core/src/__tests__/renderer.test.ts @@ -0,0 +1,37 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +import { describe, expect, it } from 'vitest'; + +import { replaceWrappedIds } from '../renderers/renderer'; + +describe('replaceWrappedIds', () => { + it('replaces ids with names', () => { + const source = fs.readFileSync(path.resolve(__dirname, 'file.ts'), { + encoding: 'utf8', + }); + + const substitutions: Record = { + 1: 'Foo', + 12: 'baz', + 2: 'bar', + 4: '() => string', + 5: 'string', + }; + + const replaced = replaceWrappedIds(source, (id) => substitutions[id]); + + expect(replaced).toEqual(`/* @ts-nocheck */ + +/** + * something about Foo. Did you know that _Foo_? + */ +export class Foo { + // Foo is great! + bar(baz: ReturnType<() => string>): string { + return baz; + } +} +`); + }); +}); diff --git a/packages/codegen-core/src/bimap/bimap.ts b/packages/codegen-core/src/bimap/bimap.ts new file mode 100644 index 000000000..c2cc9ef8f --- /dev/null +++ b/packages/codegen-core/src/bimap/bimap.ts @@ -0,0 +1,64 @@ +import type { ICodegenBiMap } from './types'; + +export class BiMap implements ICodegenBiMap { + private map = new Map(); + private reverse = new Map(); + + delete(key: Key): boolean { + const value = this.map.get(key); + if (value !== undefined) { + this.reverse.delete(value); + } + return this.map.delete(key); + } + + deleteValue(value: Value): boolean { + const key = this.reverse.get(value); + if (key !== undefined) { + this.map.delete(key); + } + return this.reverse.delete(value); + } + + entries(): IterableIterator<[Key, Value]> { + return this.map.entries(); + } + + get(key: Key): Value | undefined { + return this.map.get(key); + } + + getKey(value: Value): Key | undefined { + return this.reverse.get(value); + } + + hasKey(key: Key): boolean { + return this.map.has(key); + } + + hasValue(value: Value): boolean { + return this.reverse.has(value); + } + + keys(): IterableIterator { + return this.map.keys(); + } + + set(key: Key, value: Value): this { + this.map.set(key, value); + this.reverse.set(value, key); + return this; + } + + get size(): number { + return this.map.size; + } + + values(): IterableIterator { + return this.map.values(); + } + + [Symbol.iterator](): IterableIterator<[Key, Value]> { + return this.map[Symbol.iterator](); + } +} diff --git a/packages/codegen-core/src/bimap/types.d.ts b/packages/codegen-core/src/bimap/types.d.ts new file mode 100644 index 000000000..610d6b2f3 --- /dev/null +++ b/packages/codegen-core/src/bimap/types.d.ts @@ -0,0 +1,74 @@ +/** + * Bi-directional map interface. + * + * Keys map to values and values map back to keys. + * + * @template Key Type of the map keys + * @template Value Type of the map values + */ +export interface ICodegenBiMap { + /** + * Deletes a key and its associated value from the map. + * + * @param key The key to delete. + */ + delete(key: Key): boolean; + /** + * Deletes a value and its associated key from the map. + * + * @param value The value to delete. + */ + deleteValue(value: Value): boolean; + /** + * Returns an iterator of [key, value] pairs. + */ + entries(): IterableIterator<[Key, Value]>; + /** + * Gets the value associated with a key. + * + * @param key The key to look up. + */ + get(key: Key): Value | undefined; + /** + * Gets the key associated with a value. + * + * @param value The value to look up. + */ + getKey(value: Value): Key | undefined; + /** + * Checks if a key exists in the map. + * + * @param key The key to check. + */ + hasKey(key: Key): boolean; + /** + * Checks if a value exists in the map. + * + * @param value The value to check. + */ + hasValue(value: Value): boolean; + /** + * Returns an iterator of keys. + */ + keys(): IterableIterator; + /** + * Sets a key-value pair in the map. + * + * @param key The key. + * @param value The value. + * @returns This instance for chaining. + */ + set(key: Key, value: Value): this; + /** + * Number of key-value pairs in the map. + */ + readonly size: number; + /** + * Returns an iterator of values. + */ + values(): IterableIterator; + /** + * Enables iteration with `for...of`. + */ + [Symbol.iterator](): IterableIterator<[Key, Value]>; +} diff --git a/packages/codegen-core/src/files/file.ts b/packages/codegen-core/src/files/file.ts index 82f19fc87..a372f6f3c 100644 --- a/packages/codegen-core/src/files/file.ts +++ b/packages/codegen-core/src/files/file.ts @@ -1,28 +1,42 @@ import path from 'node:path'; +import { BiMap } from '../bimap/bimap'; +import type { ICodegenBiMap } from '../bimap/types'; import type { ICodegenImport } from '../imports/types'; -import type { ICodegenSymbol } from '../symbols/types'; +import type { ICodegenProject } from '../project/types'; +import { wrapId } from '../renderers/renderer'; +import type { + ICodegenSymbolIn, + ICodegenSymbolOut, + ICodegenSymbolSelector, +} from '../symbols/types'; import type { ICodegenFile } from './types'; export class CodegenFile implements ICodegenFile { private cache: { exports?: ReadonlyArray; imports?: ReadonlyArray; - symbols?: ReadonlyArray; + symbols?: ReadonlyArray; } = {}; + private renderSymbols: Array = []; + private state: { exports: Map; imports: Map; - symbols: Map; + symbols: Map; } = { exports: new Map(), imports: new Map(), symbols: new Map(), }; + id: number; + resolvedNames: ICodegenBiMap = new BiMap(); + constructor( public path: string, + public project: ICodegenProject, public meta: ICodegenFile['meta'] = {}, ) { let filePath = CodegenFile.pathToFilePath(path); @@ -33,6 +47,7 @@ export class CodegenFile implements ICodegenFile { filePath = meta.path.replace('{{path}}', filePath); } } + this.id = project.incrementFileId(); this.path = filePath; } @@ -48,27 +63,61 @@ export class CodegenFile implements ICodegenFile { value: ICodegenImport, field: 'exports' | 'imports', ): void { - const key = typeof value.from === 'string' ? value.from : value.from.path; + const key = this.getImportExportKey(value); const existing = this.state[field].get(key); + // cast type names to names to allow for cleaner API, + // otherwise users would have to define the same values twice + if (!value.names) value.names = []; + for (const typeName of value.typeNames ?? []) { + if (!value.names.includes(typeName)) { + value.names = [...value.names, typeName]; + } + } if (existing) { this.mergeImportExportValues(existing, value); this.state[field].set(key, existing); } else { this.state[field].set(key, { ...value }); // clone to avoid mutation } - this.cache[field] = undefined; + this.cache[field] = undefined; // invalidate cache } - addSymbol(symbol: ICodegenSymbol): void { - const key = symbol.name; - const existing = this.state.symbols.get(key); - if (existing) { - existing.value = symbol.value; - this.state.symbols.set(key, existing); - } else { - this.state.symbols.set(key, { ...symbol }); // clone to avoid mutation + private addRenderSymbol(id: number): void { + this.renderSymbols.push(id); + this.cache.symbols = undefined; // invalidate cache + } + + addSymbol(symbol: ICodegenSymbolIn): ICodegenSymbolOut { + const id = this.project.incrementSymbolId(); + const inserted: ICodegenSymbolOut = { + ...symbol, // clone to avoid mutation + file: this, + id, + placeholder: wrapId(String(id)), + update: (values) => this.updateSymbol(id, values), + }; + if (inserted.value === undefined) { + // register symbols without value as headless + inserted.headless = true; + } else if (!inserted.headless) { + delete inserted.headless; } - this.cache.symbols = undefined; + this.state.symbols.set(id, inserted); + this.project.registerSymbol(inserted, this); + if (!inserted.headless) { + this.addRenderSymbol(id); + } + return inserted; + } + + ensureSymbol( + symbol: Partial & + Pick, 'selector'>, + ): ICodegenSymbolOut { + return ( + this.selectSymbolFirst(symbol.selector) || + this.addSymbol({ name: '', ...symbol }) + ); } get exports(): ReadonlyArray { @@ -78,7 +127,7 @@ export class CodegenFile implements ICodegenFile { return this.cache.exports; } - getAllSymbols(): ReadonlyArray { + getAllSymbols(): ReadonlyArray> { return [ ...this.symbols, ...this.imports.flatMap((imp) => @@ -94,12 +143,23 @@ export class CodegenFile implements ICodegenFile { ]; } + private getImportExportKey(value: ICodegenImport): string { + if (typeof value.from === 'string') { + return value.from; + } + return value.from.path; + } + + getSymbolById(id: number): ICodegenSymbolOut | undefined { + return this.state.symbols.get(id); + } + hasContent(): boolean { - return this.state.symbols.size > 0 || this.state.exports.size > 0; + return this.state.exports.size > 0 || this.symbols.length > 0; } - hasSymbol(name: string): boolean { - return this.state.symbols.has(name); + hasSymbol(id: number): boolean { + return this.state.symbols.has(id); } get imports(): ReadonlyArray { @@ -166,10 +226,56 @@ export class CodegenFile implements ICodegenFile { return relativePath; } - get symbols(): ReadonlyArray { + selectSymbolAll( + selector: ICodegenSymbolSelector, + ): ReadonlyArray { + return this.project.selectSymbolAll(selector, this); + } + + selectSymbolFirst( + selector: ICodegenSymbolSelector, + ): ICodegenSymbolOut | undefined { + return this.project.selectSymbolFirst(selector, this); + } + + selectSymbolFirstOrThrow( + selector: ICodegenSymbolSelector, + ): ICodegenSymbolOut { + return this.project.selectSymbolFirstOrThrow(selector, this); + } + + selectSymbolLast( + selector: ICodegenSymbolSelector, + ): ICodegenSymbolOut | undefined { + return this.project.selectSymbolLast(selector, this); + } + + get symbols(): ReadonlyArray { if (!this.cache.symbols) { - this.cache.symbols = Array.from(this.state.symbols.values()); + this.cache.symbols = this.renderSymbols.map( + (id) => this.getSymbolById(id)!, + ); } return this.cache.symbols; } + + updateSymbol( + id: number, + symbol: Partial, + ): ICodegenSymbolOut { + const existing = this.getSymbolById(id); + if (!existing) { + throw new Error(`symbol with id ${id} not found`); + } + const updated: ICodegenSymbolOut = { ...existing, ...symbol, id }; + // symbols with value can't be headless, clear redundant flag otherwise + if (!updated.headless || updated.value) { + delete updated.headless; + } + this.state.symbols.set(updated.id, updated); + if (existing.headless && !updated.headless) { + this.addRenderSymbol(id); + } + return updated; + } } diff --git a/packages/codegen-core/src/files/types.d.ts b/packages/codegen-core/src/files/types.d.ts index 9d5bdb8c4..b4740b0d6 100644 --- a/packages/codegen-core/src/files/types.d.ts +++ b/packages/codegen-core/src/files/types.d.ts @@ -1,8 +1,14 @@ +import type { ICodegenBiMap } from '../bimap/types'; import type { ICodegenImport } from '../imports/types'; +import type { ICodegenProject } from '../project/types'; import type { ICodegenRenderer } from '../renderers/types'; -import type { ICodegenSymbol } from '../symbols/types'; +import type { + ICodegenSymbolIn, + ICodegenSymbolOut, + SelectorMethods, +} from '../symbols/types'; -export interface ICodegenFile { +export interface ICodegenFile extends SelectorMethods { /** * Adds an export to this file. * @@ -22,7 +28,20 @@ export interface ICodegenFile { * * @param symbol The symbol to add */ - addSymbol(symbol: ICodegenSymbol): void; + addSymbol(symbol: ICodegenSymbolIn): ICodegenSymbolOut; + /** + * Ensures a symbol for the given selector exists, so it can be + * safely used. + * + * @param symbol The symbol to find. The required selector is used + * to match a symbol. If there's no match, we create a headless + * instance with the provided fields. + * @returns The symbol if it exists, headless instance otherwise. + */ + ensureSymbol( + symbol: Partial & + Pick, 'selector'>, + ): ICodegenSymbolOut; /** * Symbols exported from other files. **/ @@ -32,7 +51,14 @@ export interface ICodegenFile { * * @returns List of all symbols used in this file */ - getAllSymbols(): ReadonlyArray; + getAllSymbols(): ReadonlyArray>; + /** + * Finds a symbol by symbol ID. + * + * @param id Symbol ID + * @returns The symbol if it exists, undefined otherwise. + */ + getSymbolById(id: number): ICodegenSymbolOut | undefined; /** * Checks if this file contains any content. * @@ -45,10 +71,14 @@ export interface ICodegenFile { /** * Checks if this file defines a symbol with the given name. * - * @param name Symbol name to check + * @param id Symbol ID to check * @returns True if the symbol is defined by this file */ - hasSymbol(name: string): boolean; + hasSymbol(id: number): boolean; + /** + * File ID within the project. + */ + id: number; /** * Symbols imported from other files. **/ @@ -88,6 +118,10 @@ export interface ICodegenFile { * @example "models/user.ts" */ path: string; + /** + * Parent project this file belongs to. + */ + project: ICodegenProject; /** * Returns a relative path to this file from another file. * @@ -102,8 +136,23 @@ export interface ICodegenFile { * @example "./another-file.ts" */ relativePathToFile(file: Pick): string; + /** + * Map holding resolved names for symbols in this file. + */ + resolvedNames: ICodegenBiMap; /** * Top-level symbols declared in this file. **/ - symbols: ReadonlyArray; + symbols: ReadonlyArray; + /** + * Updates a symbol defined by this file. + * + * @param id ID of symbol to update. + * @param symbol The values to update. + * @returns The updated symbol. + */ + updateSymbol( + id: number, + symbol: Partial, + ): ICodegenSymbolOut; } diff --git a/packages/codegen-core/src/index.ts b/packages/codegen-core/src/index.ts index 39b55a169..be3437749 100644 --- a/packages/codegen-core/src/index.ts +++ b/packages/codegen-core/src/index.ts @@ -1,3 +1,5 @@ +export { BiMap } from './bimap/bimap'; +export type { ICodegenBiMap } from './bimap/types'; export { CodegenFile } from './files/file'; export type { ICodegenFile } from './files/types'; export type { ICodegenImport } from './imports/types'; @@ -5,5 +7,10 @@ export type { ICodegenMeta } from './meta/types'; export type { ICodegenOutput } from './output/types'; export { CodegenProject } from './project/project'; export type { ICodegenProject } from './project/types'; +export { replaceWrappedIds } from './renderers/renderer'; export type { ICodegenRenderer } from './renderers/types'; -export type { ICodegenSymbol } from './symbols/types'; +export type { + ICodegenSymbolIn, + ICodegenSymbolOut, + ICodegenSymbolSelector, +} from './symbols/types'; diff --git a/packages/codegen-core/src/project/project.ts b/packages/codegen-core/src/project/project.ts index f859c69f3..b966601d2 100644 --- a/packages/codegen-core/src/project/project.ts +++ b/packages/codegen-core/src/project/project.ts @@ -1,44 +1,55 @@ import { CodegenFile } from '../files/file'; +import type { ICodegenFile } from '../files/types'; import type { ICodegenImport } from '../imports/types'; import type { ICodegenMeta } from '../meta/types'; import type { ICodegenOutput } from '../output/types'; +import { replaceWrappedIds } from '../renderers/renderer'; import type { ICodegenRenderer } from '../renderers/types'; -import type { ICodegenSymbol } from '../symbols/types'; +import type { + ICodegenSymbolIn, + ICodegenSymbolOut, + ICodegenSymbolSelector, +} from '../symbols/types'; import type { ICodegenProject } from './types'; export class CodegenProject implements ICodegenProject { - private filesMap: Map = new Map(); - private filesOrder: Array = []; + private fileId: number = 0; + private fileIdToFile: Map = new Map(); + private fileOrder: Array = []; + private filePathToFileId: Map = new Map(); private renderers: Map = new Map(); + private selectorToSymbolIds: Map> = new Map(); + private symbolId: number = 0; + private symbolIdToFileId: Map = new Map(); - addExportToFile(fileOrPath: CodegenFile | string, imp: ICodegenImport): void { + addExport(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void { const file = this.ensureFile(fileOrPath); file.addExport(imp); } - addImportToFile(fileOrPath: CodegenFile | string, imp: ICodegenImport): void { + addImport(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void { const file = this.ensureFile(fileOrPath); file.addImport(imp); } - addSymbolToFile( - fileOrPath: CodegenFile | string, - symbol: ICodegenSymbol, - ): void { + addSymbol( + fileOrPath: ICodegenFile | string, + symbol: ICodegenSymbolIn, + ): ICodegenSymbolOut { const file = this.ensureFile(fileOrPath); - file.addSymbol(symbol); + return file.addSymbol(symbol); } createFile( path: string, - meta: Omit & { + meta: Omit & { /** * Renderer to use to render this file. */ renderer?: ICodegenRenderer; } = {}, - ): CodegenFile { - const { renderer, ...metadata } = meta; + ): ICodegenFile { + const { renderer, ..._meta } = meta; if (renderer) { this.ensureRenderer(renderer); } @@ -52,16 +63,17 @@ export class CodegenProject implements ICodegenProject { return existing; } - const file = new CodegenFile(path, { - ...metadata, + const file = new CodegenFile(path, this, { + ..._meta, renderer: renderer?.id, }); - this.filesOrder.push(file); - this.filesMap.set(path, file); + this.fileOrder.push(file); + this.filePathToFileId.set(path, file.id); + this.fileIdToFile.set(file.id, file); return file; } - ensureFile(fileOrPath: CodegenFile | string): CodegenFile { + ensureFile(fileOrPath: ICodegenFile | string): ICodegenFile { if (typeof fileOrPath !== 'string') { return fileOrPath; } @@ -79,26 +91,117 @@ export class CodegenProject implements ICodegenProject { return this.renderers.get(renderer.id)!; } - get files(): ReadonlyArray { - return [...this.filesOrder]; + get files(): ReadonlyArray { + return [...this.fileOrder]; } - getAllSymbols(): ReadonlyArray { - return this.filesOrder.flatMap((file) => file.getAllSymbols()); + getAllSymbols(): ReadonlyArray> { + return this.fileOrder.flatMap((file) => file.getAllSymbols()); } - getFileByPath(path: string): CodegenFile | undefined { - return this.filesMap.get(path); + getFileByPath(path: string): ICodegenFile | undefined { + const fileId = this.filePathToFileId.get(path); + return fileId !== undefined ? this.fileIdToFile.get(fileId) : undefined; + } + + getFileBySymbolId(id: number): ICodegenFile | undefined { + const fileId = this.symbolIdToFileId.get(id); + return fileId !== undefined ? this.fileIdToFile.get(fileId) : undefined; + } + + private getFileRenderer(file: ICodegenFile): ICodegenRenderer | undefined { + return file.meta.renderer + ? this.renderers.get(file.meta.renderer) + : undefined; + } + + getSymbolById(id: number): ICodegenSymbolOut | undefined { + const file = this.getFileBySymbolId(id); + return file?.getSymbolById(id); + } + + incrementFileId(): number { + return this.fileId++; + } + + incrementSymbolId(): number { + return this.symbolId++; + } + + registerSymbol(symbol: ICodegenSymbolOut, file: ICodegenFile): void { + this.symbolIdToFileId.set(symbol.id, file.id); + if (symbol.selector) { + const selector = JSON.stringify(symbol.selector); + const ids = this.selectorToSymbolIds.get(selector) ?? []; + ids.push(symbol.id); + this.selectorToSymbolIds.set(selector, ids); + } } render(meta?: ICodegenMeta): ReadonlyArray { const results: Array = []; - for (const file of this.filesOrder) { - if (!file.meta.renderer) continue; - const renderer = this.renderers.get(file.meta.renderer); - if (!renderer) continue; - results.push(renderer.render(file, meta)); + this.fileOrder.forEach((file, index) => { + const renderer = this.getFileRenderer(file); + if (!renderer) return; + results[index] = { + content: renderer.renderSymbols(file, meta), + meta: file.meta, + path: `${file.path}${file.meta.extension ?? ''}`, + }; + }); + this.fileOrder.forEach((file, index) => { + const renderer = this.getFileRenderer(file); + if (!renderer || !results[index]) return; + const header = renderer.renderHeader(file, meta); + const content = replaceWrappedIds(results[index].content, (symbolId) => + renderer.replacerFn({ file, symbolId }), + ); + results[index].content = `${header}${content}`; + }); + return results.filter(Boolean); + } + + selectSymbolAll( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ReadonlyArray { + const ids = this.selectorToSymbolIds.get(JSON.stringify(selector)) ?? []; + const symbols: Array = []; + for (const id of ids) { + const f = this.getFileBySymbolId(id); + if (!f || (file && file !== f)) continue; + const symbol = f.getSymbolById(id); + if (!symbol) continue; + symbols.push(symbol); } - return results; + return symbols; + } + + selectSymbolFirst( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ICodegenSymbolOut | undefined { + const symbols = this.selectSymbolAll(selector, file); + return symbols[0]; + } + + selectSymbolFirstOrThrow( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ICodegenSymbolOut { + const symbol = this.selectSymbolFirst(selector, file); + if (!symbol) + throw new Error( + `symbol for selector not found: ${JSON.stringify(selector)}`, + ); + return symbol; + } + + selectSymbolLast( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ICodegenSymbolOut | undefined { + const symbols = this.selectSymbolAll(selector, file); + return symbols[symbols.length - 1]; } } diff --git a/packages/codegen-core/src/project/types.d.ts b/packages/codegen-core/src/project/types.d.ts index 46551e2dc..b60f1c779 100644 --- a/packages/codegen-core/src/project/types.d.ts +++ b/packages/codegen-core/src/project/types.d.ts @@ -3,43 +3,48 @@ import type { ICodegenImport } from '../imports/types'; import type { ICodegenMeta } from '../meta/types'; import type { ICodegenOutput } from '../output/types'; import type { ICodegenRenderer } from '../renderers/types'; -import type { ICodegenSymbol } from '../symbols/types'; +import type { + ICodegenSymbolIn, + ICodegenSymbolOut, + SelectorMethods, +} from '../symbols/types'; /** * Represents a code generation project consisting of multiple codegen files. * Manages imports, symbols, and output generation across the project. */ -export interface ICodegenProject { +export interface ICodegenProject extends SelectorMethods { /** * Adds an export declaration to a specific file, creating the file if it doesn't exist. * * @param fileOrPath - File instance or file path where to add the export. * @param imp - The export declaration to add. * @example - * project.addExportToFile("models/user.ts", { from: "lib", names: ["User"] }); + * project.addExport("models/user.ts", { from: "lib", names: ["User"] }); */ - addExportToFile(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void; + addExport(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void; /** * Adds an import declaration to a specific file, creating the file if it doesn't exist. * * @param fileOrPath - File instance or file path where to add the import. * @param imp - The import declaration to add. * @example - * project.addImportToFile("models/user.ts", { from: "lib", names: ["User"] }); + * project.addImport("models/user.ts", { from: "lib", names: ["User"] }); */ - addImportToFile(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void; + addImport(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void; /** * Adds a symbol to a specific file, creating the file if it doesn't exist. * * @param fileOrPath - File instance or file path where to add the symbol. * @param symbol - The symbol to add. + * @returns The inserted symbol. * @example - * project.addSymbolToFile("models/user.ts", { name: "User", value: tsNode }); + * project.addSymbol("models/user.ts", { name: "User", value: tsNode }); */ - addSymbolToFile( + addSymbol( fileOrPath: ICodegenFile | string, - symbol: ICodegenSymbol, - ): void; + symbol: ICodegenSymbolIn, + ): ICodegenSymbolOut; /** * Creates a new codegen file with optional metadata and adds it to the project. * @@ -82,7 +87,7 @@ export interface ICodegenProject { * @example * project.getAllSymbols().filter(s => s.name === "User"); */ - getAllSymbols(): ReadonlyArray; + getAllSymbols(): ReadonlyArray>; /** * Retrieves a file by its logical output path. * @@ -92,6 +97,43 @@ export interface ICodegenProject { * const file = project.getFileByPath("models/user.ts"); */ getFileByPath(path: string): ICodegenFile | undefined; + /** + * Retrieves a file from symbol ID included in the file. + * + * @param id The symbol ID to find. + * @returns The file if found, undefined otherwise. + * @example + * const file = project.getFileBySymbolId(31); + */ + getFileBySymbolId(id: number): ICodegenFile | undefined; + /** + * Retrieves a symbol from ID included in the project. + * + * @param id The symbol ID to find. + * @returns The symbol if found, undefined otherwise. + * @example + * const symbol = project.getSymbolById(31); + */ + getSymbolById(id: number): ICodegenSymbolOut | undefined; + /** + * Returns the current file ID and increments it. + * + * @returns File ID before being incremented + */ + incrementFileId(): number; + /** + * Returns the current symbol ID and increments it. + * + * @returns Symbol ID before being incremented + */ + incrementSymbolId(): number; + /** + * Tracks added symbol across the project. + * + * @param symbol The symbol added to file. + * @param file The file containing the added symbol. + */ + registerSymbol(symbol: ICodegenSymbolOut, file: ICodegenFile): void; /** * Produces output representations for all files in the project. * diff --git a/packages/codegen-core/src/renderers/renderer.ts b/packages/codegen-core/src/renderers/renderer.ts new file mode 100644 index 000000000..184c69316 --- /dev/null +++ b/packages/codegen-core/src/renderers/renderer.ts @@ -0,0 +1,38 @@ +/** + * Wraps an ID in namespace to avoid collisions when replacing it. + * + * @param symbolId Stringified symbol ID to use. + * @returns The wrapped placeholder ID. + */ +export const wrapId = (symbolId: string): string => `_heyapi_${symbolId}_`; + +/** + * Unwraps an ID from namespace. + * + * @param wrappedId The wrapped placeholder ID. + * @returns Stringified ID to use. + */ +const unwrapId = (wrappedId: string): string => + wrappedId.slice('_heyapi_'.length, -1); + +/** + * Returns a RegExp instance to match ID placeholders. + * + * @returns RegExp instance to match ID placeholders. + */ +const createPlaceholderRegExp = (): RegExp => new RegExp(wrapId('\\d+'), 'g'); + +/** + * + * @param source The source string to replace. + * @param replacerFn Accepts a symbol ID, returns resolved symbol name. + * @returns The replaced source string. + */ +export const replaceWrappedIds = ( + source: string, + replacerFn: (symbolId: number) => string | undefined, +): string => + source.replace(createPlaceholderRegExp(), (match) => { + const symbolId = Number.parseInt(unwrapId(match), 10); + return replacerFn(symbolId) || match; + }); diff --git a/packages/codegen-core/src/renderers/types.d.ts b/packages/codegen-core/src/renderers/types.d.ts index 1c0f10033..bcb7e0757 100644 --- a/packages/codegen-core/src/renderers/types.d.ts +++ b/packages/codegen-core/src/renderers/types.d.ts @@ -1,6 +1,5 @@ -import type { CodegenFile } from '../files/file'; +import type { ICodegenFile } from '../files/types'; import type { ICodegenMeta } from '../meta/types'; -import type { ICodegenOutput } from '../output/types'; export interface ICodegenRenderer { /** @@ -14,11 +13,30 @@ export interface ICodegenRenderer { */ id: string; /** - * Returns printable data. + * Returns printable data containing header and imports. * * @param file The file to render. * @param meta Arbitrary metadata. - * @returns Output for file emit step + * @returns Printable string containing header and imports. */ - render(file: CodegenFile, meta?: ICodegenMeta): ICodegenOutput; + renderHeader(file: ICodegenFile, meta?: ICodegenMeta): string; + /** + * Returns printable data containing symbols and exports. + * + * @param file The file to render. + * @param meta Arbitrary metadata. + * @returns Printable string containing symbols and exports. + */ + renderSymbols(file: ICodegenFile, meta?: ICodegenMeta): string; + /** + * Function replacing symbols with resolved names. + * + * @returns String with replaced symbols. + */ + replacerFn(args: { + file: ICodegenFile; + headless?: boolean; + scope?: 'file' | 'project'; + symbolId: number; + }): string | undefined; } diff --git a/packages/codegen-core/src/symbols/types.d.ts b/packages/codegen-core/src/symbols/types.d.ts index 5a07ebcdb..e9029605a 100644 --- a/packages/codegen-core/src/symbols/types.d.ts +++ b/packages/codegen-core/src/symbols/types.d.ts @@ -1,25 +1,130 @@ -export interface ICodegenSymbol { +import type { ICodegenFile } from '../files/types'; + +/** + * Selector array used to select symbols. It doesn't have to be + * unique, but in practice it might be desirable. + * + * @example ["zod", "#/components/schemas/Foo"] + */ +export type ICodegenSymbolSelector = ReadonlyArray; + +export interface ICodegenSymbolIn { /** - * Optional description or doc comment. + * Symbols can be **headed** or **headless**. * - * @example "Represents a user in the system" + * Headless symbols never render their `value`. Headed symbols render their + * `value` if defined. + * + * Symbols are rendered in the order they were registered as headed. + * + * Example 1: We register headless symbol `foo`, headed `bar`, and headed + * `foo`. The render order is [`bar`, `foo`]. + * + * Example 2: We register headed symbol `foo` and headed `bar`. The render + * order is [`foo`, `bar`]. + * + * Headless symbols can be used to claim a symbol or to represent imports + * or exports. + * + * @default false */ - description?: string; + headless?: boolean; /** - * Optional kind of symbol (e.g. "class", "function", "type", etc.). + * The desired name for the symbol within its file. If there are multiple symbols + * with the same desired name, this might not end up being the actual name. * - * @example "class" + * @example "UserModel" */ - kind?: string; + readonly name: string; /** - * Unique identifier for the symbol within its file. + * Selector array used to select this symbol. It doesn't have to be + * unique, but in practice it might be desirable. * - * @example "UserModel" + * @example ["zod", "#/components/schemas/Foo"] + */ + readonly selector?: ICodegenSymbolSelector; + /** + * Internal representation of the symbol (e.g. AST node, IR object, raw code). + * Used to generate output. If left undefined, this symbol becomes `headless`. + */ + readonly value?: unknown; +} + +export interface ICodegenSymbolOut extends ICodegenSymbolIn { + /** + * The file this symbol is located in. */ - name: string; + readonly file: ICodegenFile; /** - * Internal representation of the symbol (e.g. AST node, IR object, raw - * code). Used to generate output. + * Unique symbol ID. + */ + readonly id: number; + /** + * Placeholder name for the symbol to be replaced later with the final value. + * + * @example "_heyapi_31_" + */ + readonly placeholder: string; + /** + * Updates this symbol. + * + * @param symbol The values to update. + * @returns The updated symbol. + */ + readonly update: (symbol: Partial) => ICodegenSymbolOut; +} + +export interface SelectorMethods { + /** + * Retrieves symbols matching the selector. + * + * @param selector The symbol selector to find. + * @param file Find symbols only in this file. + * @returns The array of all symbols matching the selector. + * @example + * const symbols = project.selectSymbolAll(["zod", "#/components/schemas/Foo"]); + */ + selectSymbolAll( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ReadonlyArray; + /** + * Retrieves the first symbol from all symbols matching the selector. + * + * @param selector The symbol selector to find. + * @param file Find symbols only in this file. + * @returns The symbol if found, or undefined otherwise. + * @example + * const symbol = project.selectSymbolFirst(["zod", "#/components/schemas/Foo"]); + */ + selectSymbolFirst( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ICodegenSymbolOut | undefined; + /** + * Retrieves the first symbol from all symbols matching the selector. + * + * @param selector The symbol selector to find. + * @param file Find symbols only in this file. + * @returns The symbol if found, or throw otherwise. + * @example + * const symbol = project.selectSymbolFirstOrThrow(["zod", "#/components/schemas/Foo"]); + */ + selectSymbolFirstOrThrow( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ICodegenSymbolOut; + /** + * Retrieves the last symbol from all symbols matching the selector. + * + * @param selector The symbol selector to find. + * @param file Find symbols only in this file. + * @returns The symbol if found, or undefined otherwise. + * @example + * const symbol = project.selectSymbolLast(["zod", "#/components/schemas/Foo"]); */ - value?: unknown; + selectSymbolLast( + selector: ICodegenSymbolSelector, + file?: ICodegenFile, + ): ICodegenSymbolOut | undefined; } diff --git a/packages/custom-client/package.json b/packages/custom-client/package.json index 69efce5bf..78e6e318d 100644 --- a/packages/custom-client/package.json +++ b/packages/custom-client/package.json @@ -63,10 +63,12 @@ "typecheck": "vitest --typecheck --watch=false" }, "peerDependencies": { + "@hey-api/codegen-core": "<2", "@hey-api/openapi-ts": "<2" }, "devDependencies": { "@config/vite-base": "workspace:*", + "@hey-api/codegen-core": "workspace:*", "@hey-api/openapi-ts": "workspace:*" } } diff --git a/packages/custom-client/src/plugin.ts b/packages/custom-client/src/plugin.ts index d7045d6ae..fc868ad33 100644 --- a/packages/custom-client/src/plugin.ts +++ b/packages/custom-client/src/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,6 +8,28 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; +type SelectorType = 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} + export type Config = Client.Config & { /** * Plugin name. Must be unique. @@ -14,10 +37,13 @@ export type Config = Client.Config & { name: '@hey-api/custom-client'; }; -export type CustomClientPlugin = DefinePlugin; +export type CustomClientPlugin = DefinePlugin; export const defaultConfig: CustomClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: '@hey-api/custom-client', + }), config: { ...clientDefaultConfig, bundle: false, diff --git a/packages/openapi-ts-tests/main/package.json b/packages/openapi-ts-tests/main/package.json index 091b5064b..6fffb763e 100644 --- a/packages/openapi-ts-tests/main/package.json +++ b/packages/openapi-ts-tests/main/package.json @@ -27,6 +27,7 @@ "@angular/platform-browser-dynamic": "19.2.0", "@angular/router": "19.2.0", "@config/vite-base": "workspace:*", + "@hey-api/codegen-core": "workspace:*", "@hey-api/custom-client": "workspace:*", "@hey-api/openapi-ts": "workspace:*", "@pinia/colada": "0.17.2", diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/types.gen.ts index cadf9fe79..62bdb7f98 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/types.gen.ts @@ -12,4 +12,4 @@ export type Baz = Foo & { export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/types.gen.ts index 97d07f4c8..067709e9c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-true/types.gen.ts @@ -20,4 +20,4 @@ export type Qux = { export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/sdk.gen.ts index 886e60b1d..d0712e097 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ bodySerializer: null, url: '/foo', ...options, @@ -28,4 +28,4 @@ export const postFoo = (options: Options

= (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/sdk.gen.ts index 8f7c4c500..99b508c95 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer } from './client'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer } from './client'; import type { PostV1FooData, PostV1FooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/v1/foo', ...options, @@ -28,4 +28,4 @@ export const postV1Foo = (options: Options ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/types.gen.ts index 35f2e9d76..7b434343a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/types.gen.ts @@ -25,4 +25,4 @@ export type PostV1FooResponse = PostV1FooResponses[keyof PostV1FooResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts index fae644c0c..e28017eaf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts index 005a668e0..2d5985b31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options = export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts index dd1bb7d5b..4ff334ff7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,21 +20,21 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/business/providers/domains', ...options }); } public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/business/providers/domains', ...options }); } public static putBusinessProvidersDomains(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/business/providers/domains', ...options }); @@ -47,7 +47,7 @@ class Providers { export class Business { public static get(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/locations/businesses', ...options }); @@ -57,10 +57,10 @@ export class Business { export class Locations { public static get(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/locations', ...options }); } static business = Business; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts index 95401d19c..3c9d90569 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts @@ -82,4 +82,4 @@ export type GetResponse = GetResponses[keyof GetResponses]; export type ClientOptions = { baseUrl: 'https://api.example.com/v1' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts index 466f10c45..5f6dbe077 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts @@ -756,4 +756,4 @@ export const ModelWithPatternWritableSchema = { pattern: 'aaa`bbb' } } -} as const; \ No newline at end of file +} as const; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts index 836b0ecb6..b215924fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts index ebc3a8457..4cf0ca9c4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base', throwOnError: true -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts index 850feac82..4140ac376 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: O }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (op ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts index 20c92fc95..5c161731c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { postFooResponseTransformer } from './transformers.gen'; -import { vPostFooResponse } from './valibot.gen'; +import { vPostFooData, vPostFooResponse } from './valibot.gen'; import * as v from 'valibot'; -import { client as _heyApiClient } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,7 +22,10 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ + requestValidator: async (data) => { + return await v.parseAsync(vPostFooData, data); + }, responseTransformer: postFooResponseTransformer, responseValidator: async (data) => { return await v.parseAsync(vPostFooResponse, data); @@ -30,4 +33,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts index 419690a91..cc9dcf841 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts @@ -10,4 +10,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const postFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts index baee77c9b..2b264a4ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts @@ -33,4 +33,4 @@ export type UserId = TypeID<'user'>; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts index e49e2e14e..a030d9354 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts @@ -25,4 +25,4 @@ export const vPostFooData = v.object({ /** * OK */ -export const vPostFooResponse = vFoo; \ No newline at end of file +export const vPostFooResponse = vFoo; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts index 67d605869..9067c31ee 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts @@ -1,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; import { zPostFooData, zPostFooResponse } from './zod.gen'; import { postFooResponseTransformer } from './transformers.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -21,7 +21,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ requestValidator: async (data) => { return await zPostFooData.parseAsync(data); }, @@ -32,4 +32,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts index 419690a91..cc9dcf841 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts @@ -10,4 +10,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const postFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts index baee77c9b..2b264a4ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts @@ -33,4 +33,4 @@ export type UserId = TypeID<'user'>; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts index bfee2ff85..477553d5c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts index 177cb41a1..a7f908ad2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts @@ -58,4 +58,4 @@ export type PostFooReadResponse = PostFooReadResponses[keyof PostFooReadResponse export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts index 4011dbecf..54931798c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts @@ -46,4 +46,4 @@ export type PostFooReadResponse = PostFooReadResponses[keyof PostFooReadResponse export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts index d76d2345b..3d7ea87eb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts @@ -3,7 +3,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, callWithDescriptions, callWithParameters, callWithWeirdParameterNames, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, complexTypes, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, postApiVbyApiVersionBody } from '../sdk.gen'; import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyBData, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, ComplexTypesData, ComplexTypesResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -18,7 +18,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (tags) { params.tags = tags as unknown as undefined; } @@ -493,4 +493,4 @@ export const postApiVbyApiVersionBodyMutation = (options: Options = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts index 836b0ecb6..b215924fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts deleted file mode 100644 index 27d358cc3..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, collectionFormat } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { CollectionFormatData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const collectionFormatQueryKey = (options: Options) => createQueryKey('collectionFormat', options); - -export const collectionFormatQuery = (options: Options): UseQueryOptions => { - return { - key: collectionFormatQueryKey(options), - query: async (context) => { - const { data } = await collectionFormat({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts deleted file mode 100644 index 0c83c1c86..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, complexTypes } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { ComplexTypesData, ComplexTypesResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const complexTypesQueryKey = (options: Options) => createQueryKey('complexTypes', options); - -export const complexTypesQuery = (options: Options): UseQueryOptions => { - return { - key: complexTypesQueryKey(options), - query: async (context) => { - const { data } = await complexTypes({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts deleted file mode 100644 index 47f7894bf..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts +++ /dev/null @@ -1,82 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithDefaultParametersQueryKey = (options: Options) => createQueryKey('callWithDefaultParameters', options); - -export const callWithDefaultParametersQuery = (options: Options): UseQueryOptions => { - return { - key: callWithDefaultParametersQueryKey(options), - query: async (context) => { - const { data } = await callWithDefaultParameters({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithDefaultOptionalParametersMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDefaultOptionalParameters({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callToTestOrderOfParamsMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callToTestOrderOfParams({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts deleted file mode 100644 index 05f30e6d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithDescriptions } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { CallWithDescriptionsData } from '../../types.gen'; - -export const callWithDescriptionsMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDescriptions({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts deleted file mode 100644 index ed05f186b..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts +++ /dev/null @@ -1,95 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, duplicateName, duplicateName2, duplicateName3, duplicateName4 } from '../../sdk.gen'; -import type { UseMutationOptions, _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export const duplicateNameMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const duplicateName2QueryKey = (options?: Options) => createQueryKey('duplicateName2', options); - -export const duplicateName2Query = (options?: Options): UseQueryOptions => { - return { - key: duplicateName2QueryKey(options), - query: async (context) => { - const { data } = await duplicateName2({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const duplicateName3Mutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName3({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const duplicateName4Mutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName4({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts deleted file mode 100644 index 90dc048d7..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, testErrorCode } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { TestErrorCodeData } from '../../types.gen'; - -export const testErrorCodeMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await testErrorCode({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts deleted file mode 100644 index 2100075e4..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithResultFromHeader } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { CallWithResultFromHeaderData } from '../../types.gen'; - -export const callWithResultFromHeaderMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithResultFromHeader({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts deleted file mode 100644 index 28b444298..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts +++ /dev/null @@ -1,72 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, dummyA, dummyB } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DummyAData, DummyBData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const dummyAQueryKey = (options?: Options) => createQueryKey('dummyA', options); - -export const dummyAQuery = (options?: Options): UseQueryOptions => { - return { - key: dummyAQueryKey(options), - query: async (context) => { - const { data } = await dummyA({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const dummyBQueryKey = (options?: Options) => createQueryKey('dummyB', options); - -export const dummyBQuery = (options?: Options): UseQueryOptions => { - return { - key: dummyBQueryKey(options), - query: async (context) => { - const { data } = await dummyB({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts deleted file mode 100644 index 539dc57f4..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithNoContentResponse } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { CallWithNoContentResponseData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithNoContentResponseQueryKey = (options?: Options) => createQueryKey('callWithNoContentResponse', options); - -export const callWithNoContentResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithNoContentResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithNoContentResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" deleted file mode 100644 index dc4daddff..000000000 --- "a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, nonAsciiæøåÆøÅöôêÊ字符串 } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response } from '../../types.gen'; - -export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts deleted file mode 100644 index b9c052e6f..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts +++ /dev/null @@ -1,31 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithParameters, callWithWeirdParameterNames } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { CallWithParametersData, CallWithWeirdParameterNamesData } from '../../types.gen'; - -export const callWithParametersMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithParameters({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithWeirdParameterNamesMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithWeirdParameterNames({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts deleted file mode 100644 index fb4f50eab..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts +++ /dev/null @@ -1,98 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithResponseAndNoContentResponse, callWithResponse, callWithDuplicateResponses, callWithResponses } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => createQueryKey('callWithResponseAndNoContentResponse', options); - -export const callWithResponseAndNoContentResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithResponseAndNoContentResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithResponseAndNoContentResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithResponseQueryKey = (options?: Options) => createQueryKey('callWithResponse', options); - -export const callWithResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithDuplicateResponsesMutation = (options?: Options): UseMutationOptions, CallWithDuplicateResponsesError> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDuplicateResponses({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithResponsesMutation = (options?: Options): UseMutationOptions, CallWithResponsesError> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithResponses({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts deleted file mode 100644 index 138835de5..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts +++ /dev/null @@ -1,108 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse } from '../../sdk.gen'; -import type { UseMutationOptions, _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export const deleteCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await deleteCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => createQueryKey('getCallWithoutParametersAndResponse', options); - -export const getCallWithoutParametersAndResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: getCallWithoutParametersAndResponseQueryKey(options), - query: async (context) => { - const { data } = await getCallWithoutParametersAndResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const patchCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await patchCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const postCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const putCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await putCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts deleted file mode 100644 index 822ebd8fe..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, types } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { TypesData, TypesResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const typesQueryKey = (options: Options) => createQueryKey('types', options); - -export const typesQuery = (options: Options): UseQueryOptions => { - return { - key: typesQueryKey(options), - query: async (context) => { - const { data } = await types({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts deleted file mode 100644 index 33f8fcf53..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts +++ /dev/null @@ -1,99 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, postApiVbyApiVersionBody } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const serviceWithEmptyTagQueryKey = (options?: Options) => createQueryKey('serviceWithEmptyTag', options); - -export const serviceWithEmptyTagQuery = (options?: Options): UseQueryOptions => { - return { - key: serviceWithEmptyTagQueryKey(options), - query: async (context) => { - const { data } = await serviceWithEmptyTag({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const patchApiVbyApiVersionNoTagMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await patchApiVbyApiVersionNoTag({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const fooWowMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await fooWow({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -/** - * Body should not be unknown - * Body should not be unknown - */ -export const postApiVbyApiVersionBodyMutation = (options: Options): UseMutationOptions, PostApiVbyApiVersionBodyError> => { - return { - mutation: async (fnOptions) => { - const { data } = await postApiVbyApiVersionBody({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts deleted file mode 100644 index 14f2d878c..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig = (override?: Config) => Config & T>; - -export const client = createClient(createConfig({ - baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts deleted file mode 100644 index f68339318..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ /dev/null @@ -1,267 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { createSseClient } from '../core/serverSentEvents.gen'; -import type { HttpMethod } from '../core/types.gen'; -import type { - Client, - Config, - RequestOptions, - ResolvedRequestOptions, -} from './types.gen'; -import { - buildUrl, - createConfig, - createInterceptors, - getParseAs, - mergeConfigs, - mergeHeaders, - setAuthParams, -} from './utils.gen'; - -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - -export const createClient = (config: Config = {}): Client => { - let _config = mergeConfigs(createConfig(), config); - - const getConfig = (): Config => ({ ..._config }); - - const setConfig = (config: Config): Config => { - _config = mergeConfigs(_config, config); - return getConfig(); - }; - - const interceptors = createInterceptors< - Request, - Response, - unknown, - ResolvedRequestOptions - >(); - - const beforeRequest = async (options: RequestOptions) => { - const opts = { - ..._config, - ...options, - fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, - headers: mergeHeaders(_config.headers, options.headers), - serializedBody: undefined, - }; - - if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); - } - - if (opts.requestValidator) { - await opts.requestValidator(opts); - } - - if (opts.body && opts.bodySerializer) { - opts.serializedBody = opts.bodySerializer(opts.body); - } - - // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { - opts.headers.delete('Content-Type'); - } - - const url = buildUrl(opts); - - return { opts, url }; - }; - - const request: Client['request'] = async (options) => { - // @ts-expect-error - const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', - ...opts, - body: opts.serializedBody, - }; - - let request = new Request(url, requestInit); - - for (const fn of interceptors.request._fns) { - if (fn) { - request = await fn(request, opts); - } - } - - // fetch must be assigned here, otherwise it would throw the error: - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation - const _fetch = opts.fetch!; - let response = await _fetch(request); - - for (const fn of interceptors.response._fns) { - if (fn) { - response = await fn(response, request, opts); - } - } - - const result = { - request, - response, - }; - - if (response.ok) { - const parseAs = - (opts.parseAs === 'auto' - ? getParseAs(response.headers.get('Content-Type')) - : opts.parseAs) ?? 'json'; - - if ( - response.status === 204 || - response.headers.get('Content-Length') === '0' - ) { - let emptyData: any; - switch (parseAs) { - case 'arrayBuffer': - case 'blob': - case 'text': - emptyData = await response[parseAs](); - break; - case 'formData': - emptyData = new FormData(); - break; - case 'stream': - emptyData = response.body; - break; - case 'json': - default: - emptyData = {}; - break; - } - return opts.responseStyle === 'data' - ? emptyData - : { - data: emptyData, - ...result, - }; - } - - let data: any; - switch (parseAs) { - case 'arrayBuffer': - case 'blob': - case 'formData': - case 'json': - case 'text': - data = await response[parseAs](); - break; - case 'stream': - return opts.responseStyle === 'data' - ? response.body - : { - data: response.body, - ...result, - }; - } - - if (parseAs === 'json') { - if (opts.responseValidator) { - await opts.responseValidator(data); - } - - if (opts.responseTransformer) { - data = await opts.responseTransformer(data); - } - } - - return opts.responseStyle === 'data' - ? data - : { - data, - ...result, - }; - } - - const textError = await response.text(); - let jsonError: unknown; - - try { - jsonError = JSON.parse(textError); - } catch { - // noop - } - - const error = jsonError ?? textError; - let finalError = error; - - for (const fn of interceptors.error._fns) { - if (fn) { - finalError = (await fn(error, response, request, opts)) as string; - } - } - - finalError = finalError || ({} as string); - - if (opts.throwOnError) { - throw finalError; - } - - // TODO: we probably want to return error and improve types - return opts.responseStyle === 'data' - ? undefined - : { - error: finalError, - ...result, - }; - }; - - const makeMethodFn = - (method: Uppercase) => (options: RequestOptions) => - request({ ...options, method }); - - const makeSseFn = - (method: Uppercase) => async (options: RequestOptions) => { - const { opts, url } = await beforeRequest(options); - return createSseClient({ - ...opts, - body: opts.body as BodyInit | null | undefined, - headers: opts.headers as unknown as Record, - method, - onRequest: async (url, init) => { - let request = new Request(url, init); - for (const fn of interceptors.request._fns) { - if (fn) { - request = await fn(request, opts); - } - } - return request; - }, - url, - }); - }; - - return { - buildUrl, - connect: makeMethodFn('CONNECT'), - delete: makeMethodFn('DELETE'), - get: makeMethodFn('GET'), - getConfig, - head: makeMethodFn('HEAD'), - interceptors, - options: makeMethodFn('OPTIONS'), - patch: makeMethodFn('PATCH'), - post: makeMethodFn('POST'), - put: makeMethodFn('PUT'), - request, - setConfig, - sse: { - connect: makeSseFn('CONNECT'), - delete: makeSseFn('DELETE'), - get: makeSseFn('GET'), - head: makeSseFn('HEAD'), - options: makeSseFn('OPTIONS'), - patch: makeSseFn('PATCH'), - post: makeSseFn('POST'), - put: makeSseFn('PUT'), - trace: makeSseFn('TRACE'), - }, - trace: makeMethodFn('TRACE'), - } as Client; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts deleted file mode 100644 index 318a84b6a..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -export type { Auth } from '../core/auth.gen'; -export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; -export { - formDataBodySerializer, - jsonBodySerializer, - urlSearchParamsBodySerializer, -} from '../core/bodySerializer.gen'; -export { buildClientParams } from '../core/params.gen'; -export { createClient } from './client.gen'; -export type { - Client, - ClientOptions, - Config, - CreateClientConfig, - Options, - OptionsLegacyParser, - RequestOptions, - RequestResult, - ResolvedRequestOptions, - ResponseStyle, - TDataShape, -} from './types.gen'; -export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts deleted file mode 100644 index 1a005b51e..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts +++ /dev/null @@ -1,268 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Auth } from '../core/auth.gen'; -import type { - ServerSentEventsOptions, - ServerSentEventsResult, -} from '../core/serverSentEvents.gen'; -import type { - Client as CoreClient, - Config as CoreConfig, -} from '../core/types.gen'; -import type { Middleware } from './utils.gen'; - -export type ResponseStyle = 'data' | 'fields'; - -export interface Config - extends Omit, - CoreConfig { - /** - * Base URL for all requests made by this client. - */ - baseUrl?: T['baseUrl']; - /** - * Fetch API implementation. You can use this option to provide a custom - * fetch instance. - * - * @default globalThis.fetch - */ - fetch?: typeof fetch; - /** - * Please don't use the Fetch client for Next.js applications. The `next` - * options won't have any effect. - * - * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. - */ - next?: never; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ - parseAs?: - | 'arrayBuffer' - | 'auto' - | 'blob' - | 'formData' - | 'json' - | 'stream' - | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ - responseStyle?: ResponseStyle; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ - throwOnError?: T['throwOnError']; -} - -export interface RequestOptions< - TData = unknown, - TResponseStyle extends ResponseStyle = 'fields', - ThrowOnError extends boolean = boolean, - Url extends string = string, -> extends Config<{ - responseStyle: TResponseStyle; - throwOnError: ThrowOnError; - }>, - Pick< - ServerSentEventsOptions, - | 'onSseError' - | 'onSseEvent' - | 'sseDefaultRetryDelay' - | 'sseMaxRetryAttempts' - | 'sseMaxRetryDelay' - > { - /** - * Any body that you want to add to your request. - * - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} - */ - body?: unknown; - path?: Record; - query?: Record; - /** - * Security mechanism(s) to use for the request. - */ - security?: ReadonlyArray; - url: Url; -} - -export interface ResolvedRequestOptions< - TResponseStyle extends ResponseStyle = 'fields', - ThrowOnError extends boolean = boolean, - Url extends string = string, -> extends RequestOptions { - serializedBody?: string; -} - -export type RequestResult< - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = boolean, - TResponseStyle extends ResponseStyle = 'fields', -> = ThrowOnError extends true - ? Promise< - TResponseStyle extends 'data' - ? TData extends Record - ? TData[keyof TData] - : TData - : { - data: TData extends Record - ? TData[keyof TData] - : TData; - request: Request; - response: Response; - } - > - : Promise< - TResponseStyle extends 'data' - ? - | (TData extends Record - ? TData[keyof TData] - : TData) - | undefined - : ( - | { - data: TData extends Record - ? TData[keyof TData] - : TData; - error: undefined; - } - | { - data: undefined; - error: TError extends Record - ? TError[keyof TError] - : TError; - } - ) & { - request: Request; - response: Response; - } - >; - -export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; -} - -type MethodFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'>, -) => RequestResult; - -type SseFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'>, -) => Promise>; - -type RequestFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'> & - Pick< - Required>, - 'method' - >, -) => RequestResult; - -type BuildUrlFn = < - TData extends { - body?: unknown; - path?: Record; - query?: Record; - url: string; - }, ->( - options: Pick & Options, -) => string; - -export type Client = CoreClient< - RequestFn, - Config, - MethodFn, - BuildUrlFn, - SseFn -> & { - interceptors: Middleware; -}; - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig = ( - override?: Config, -) => Config & T>; - -export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; - url: string; -} - -type OmitKeys = Pick>; - -export type Options< - TData extends TDataShape = TDataShape, - ThrowOnError extends boolean = boolean, - TResponse = unknown, - TResponseStyle extends ResponseStyle = 'fields', -> = OmitKeys< - RequestOptions, - 'body' | 'path' | 'query' | 'url' -> & - Omit; - -export type OptionsLegacyParser< - TData = unknown, - ThrowOnError extends boolean = boolean, - TResponseStyle extends ResponseStyle = 'fields', -> = TData extends { body?: any } - ? TData extends { headers?: any } - ? OmitKeys< - RequestOptions, - 'body' | 'headers' | 'url' - > & - TData - : OmitKeys< - RequestOptions, - 'body' | 'url' - > & - TData & - Pick, 'headers'> - : TData extends { headers?: any } - ? OmitKeys< - RequestOptions, - 'headers' | 'url' - > & - TData & - Pick, 'body'> - : OmitKeys, 'url'> & - TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts deleted file mode 100644 index a47509522..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts +++ /dev/null @@ -1,327 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { getAuthToken } from '../core/auth.gen'; -import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; -import { jsonBodySerializer } from '../core/bodySerializer.gen'; -import { - serializeArrayParam, - serializeObjectParam, - serializePrimitiveParam, -} from '../core/pathSerializer.gen'; -import { getUrl } from '../core/utils.gen'; -import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; - -export const createQuerySerializer = ({ - allowReserved, - array, - object, -}: QuerySerializerOptions = {}) => { - const querySerializer = (queryParams: T) => { - const search: string[] = []; - if (queryParams && typeof queryParams === 'object') { - for (const name in queryParams) { - const value = queryParams[name]; - - if (value === undefined || value === null) { - continue; - } - - if (Array.isArray(value)) { - const serializedArray = serializeArrayParam({ - allowReserved, - explode: true, - name, - style: 'form', - value, - ...array, - }); - if (serializedArray) search.push(serializedArray); - } else if (typeof value === 'object') { - const serializedObject = serializeObjectParam({ - allowReserved, - explode: true, - name, - style: 'deepObject', - value: value as Record, - ...object, - }); - if (serializedObject) search.push(serializedObject); - } else { - const serializedPrimitive = serializePrimitiveParam({ - allowReserved, - name, - value: value as string, - }); - if (serializedPrimitive) search.push(serializedPrimitive); - } - } - } - return search.join('&'); - }; - return querySerializer; -}; - -/** - * Infers parseAs value from provided Content-Type header. - */ -export const getParseAs = ( - contentType: string | null, -): Exclude => { - if (!contentType) { - // If no Content-Type header is provided, the best we can do is return the raw response body, - // which is effectively the same as the 'stream' option. - return 'stream'; - } - - const cleanContent = contentType.split(';')[0]?.trim(); - - if (!cleanContent) { - return; - } - - if ( - cleanContent.startsWith('application/json') || - cleanContent.endsWith('+json') - ) { - return 'json'; - } - - if (cleanContent === 'multipart/form-data') { - return 'formData'; - } - - if ( - ['application/', 'audio/', 'image/', 'video/'].some((type) => - cleanContent.startsWith(type), - ) - ) { - return 'blob'; - } - - if (cleanContent.startsWith('text/')) { - return 'text'; - } - - return; -}; - -const checkForExistence = ( - options: Pick & { - headers: Headers; - }, - name?: string, -): boolean => { - if (!name) { - return false; - } - if ( - options.headers.has(name) || - options.query?.[name] || - options.headers.get('Cookie')?.includes(`${name}=`) - ) { - return true; - } - return false; -}; - -export const setAuthParams = async ({ - security, - ...options -}: Pick, 'security'> & - Pick & { - headers: Headers; - }) => { - for (const auth of security) { - if (checkForExistence(options, auth.name)) { - continue; - } - - const token = await getAuthToken(auth, options.auth); - - if (!token) { - continue; - } - - const name = auth.name ?? 'Authorization'; - - switch (auth.in) { - case 'query': - if (!options.query) { - options.query = {}; - } - options.query[name] = token; - break; - case 'cookie': - options.headers.append('Cookie', `${name}=${token}`); - break; - case 'header': - default: - options.headers.set(name, token); - break; - } - } -}; - -export const buildUrl: Client['buildUrl'] = (options) => - getUrl({ - baseUrl: options.baseUrl as string, - path: options.path, - query: options.query, - querySerializer: - typeof options.querySerializer === 'function' - ? options.querySerializer - : createQuerySerializer(options.querySerializer), - url: options.url, - }); - -export const mergeConfigs = (a: Config, b: Config): Config => { - const config = { ...a, ...b }; - if (config.baseUrl?.endsWith('/')) { - config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); - } - config.headers = mergeHeaders(a.headers, b.headers); - return config; -}; - -export const mergeHeaders = ( - ...headers: Array['headers'] | undefined> -): Headers => { - const mergedHeaders = new Headers(); - for (const header of headers) { - if (!header || typeof header !== 'object') { - continue; - } - - const iterator = - header instanceof Headers ? header.entries() : Object.entries(header); - - for (const [key, value] of iterator) { - if (value === null) { - mergedHeaders.delete(key); - } else if (Array.isArray(value)) { - for (const v of value) { - mergedHeaders.append(key, v as string); - } - } else if (value !== undefined) { - // assume object headers are meant to be JSON stringified, i.e. their - // content value in OpenAPI specification is 'application/json' - mergedHeaders.set( - key, - typeof value === 'object' ? JSON.stringify(value) : (value as string), - ); - } - } - } - return mergedHeaders; -}; - -type ErrInterceptor = ( - error: Err, - response: Res, - request: Req, - options: Options, -) => Err | Promise; - -type ReqInterceptor = ( - request: Req, - options: Options, -) => Req | Promise; - -type ResInterceptor = ( - response: Res, - request: Req, - options: Options, -) => Res | Promise; - -class Interceptors { - _fns: (Interceptor | null)[]; - - constructor() { - this._fns = []; - } - - clear() { - this._fns = []; - } - - getInterceptorIndex(id: number | Interceptor): number { - if (typeof id === 'number') { - return this._fns[id] ? id : -1; - } else { - return this._fns.indexOf(id); - } - } - exists(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - return !!this._fns[index]; - } - - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; - } - } - - update(id: number | Interceptor, fn: Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; - return id; - } else { - return false; - } - } - - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; - } -} - -// `createInterceptors()` response, meant for external use as it does not -// expose internals -export interface Middleware { - error: Pick< - Interceptors>, - 'eject' | 'use' - >; - request: Pick>, 'eject' | 'use'>; - response: Pick< - Interceptors>, - 'eject' | 'use' - >; -} - -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ - error: new Interceptors>(), - request: new Interceptors>(), - response: new Interceptors>(), -}); - -const defaultQuerySerializer = createQuerySerializer({ - allowReserved: false, - array: { - explode: true, - style: 'form', - }, - object: { - explode: true, - style: 'deepObject', - }, -}); - -const defaultHeaders = { - 'Content-Type': 'application/json', -}; - -export const createConfig = ( - override: Config & T> = {}, -): Config & T> => ({ - ...jsonBodySerializer, - headers: defaultHeaders, - parseAs: 'auto', - querySerializer: defaultQuerySerializer, - ...override, -}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts deleted file mode 100644 index f8a73266f..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -export type AuthToken = string | undefined; - -export interface Auth { - /** - * Which part of the request do we use to send the auth? - * - * @default 'header' - */ - in?: 'header' | 'query' | 'cookie'; - /** - * Header or query parameter name. - * - * @default 'Authorization' - */ - name?: string; - scheme?: 'basic' | 'bearer'; - type: 'apiKey' | 'http'; -} - -export const getAuthToken = async ( - auth: Auth, - callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, -): Promise => { - const token = - typeof callback === 'function' ? await callback(auth) : callback; - - if (!token) { - return; - } - - if (auth.scheme === 'bearer') { - return `Bearer ${token}`; - } - - if (auth.scheme === 'basic') { - return `Basic ${btoa(token)}`; - } - - return token; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts deleted file mode 100644 index 49cd8925e..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { - ArrayStyle, - ObjectStyle, - SerializerOptions, -} from './pathSerializer.gen'; - -export type QuerySerializer = (query: Record) => string; - -export type BodySerializer = (body: any) => any; - -export interface QuerySerializerOptions { - allowReserved?: boolean; - array?: SerializerOptions; - object?: SerializerOptions; -} - -const serializeFormDataPair = ( - data: FormData, - key: string, - value: unknown, -): void => { - if (typeof value === 'string' || value instanceof Blob) { - data.append(key, value); - } else if (value instanceof Date) { - data.append(key, value.toISOString()); - } else { - data.append(key, JSON.stringify(value)); - } -}; - -const serializeUrlSearchParamsPair = ( - data: URLSearchParams, - key: string, - value: unknown, -): void => { - if (typeof value === 'string') { - data.append(key, value); - } else { - data.append(key, JSON.stringify(value)); - } -}; - -export const formDataBodySerializer = { - bodySerializer: | Array>>( - body: T, - ): FormData => { - const data = new FormData(); - - Object.entries(body).forEach(([key, value]) => { - if (value === undefined || value === null) { - return; - } - if (Array.isArray(value)) { - value.forEach((v) => serializeFormDataPair(data, key, v)); - } else { - serializeFormDataPair(data, key, value); - } - }); - - return data; - }, -}; - -export const jsonBodySerializer = { - bodySerializer: (body: T): string => - JSON.stringify(body, (_key, value) => - typeof value === 'bigint' ? value.toString() : value, - ), -}; - -export const urlSearchParamsBodySerializer = { - bodySerializer: | Array>>( - body: T, - ): string => { - const data = new URLSearchParams(); - - Object.entries(body).forEach(([key, value]) => { - if (value === undefined || value === null) { - return; - } - if (Array.isArray(value)) { - value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); - } else { - serializeUrlSearchParamsPair(data, key, value); - } - }); - - return data.toString(); - }, -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts deleted file mode 100644 index 71c88e852..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts +++ /dev/null @@ -1,153 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -type Slot = 'body' | 'headers' | 'path' | 'query'; - -export type Field = - | { - in: Exclude; - /** - * Field name. This is the name we want the user to see and use. - */ - key: string; - /** - * 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; - } - | { - in: Extract; - /** - * Key isn't required for bodies. - */ - key?: string; - map?: string; - }; - -export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; -} - -export type FieldsConfig = ReadonlyArray; - -const extraPrefixesMap: Record = { - $body_: 'body', - $headers_: 'headers', - $path_: 'path', - $query_: 'query', -}; -const extraPrefixes = Object.entries(extraPrefixesMap); - -type KeyMap = Map< - string, - { - in: Slot; - map?: string; - } ->; - -const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { - if (!map) { - map = new Map(); - } - - for (const config of fields) { - if ('in' in config) { - if (config.key) { - map.set(config.key, { - in: config.in, - map: config.map, - }); - } - } else if (config.args) { - buildKeyMap(config.args, map); - } - } - - return map; -}; - -interface Params { - body: unknown; - headers: Record; - path: Record; - query: Record; -} - -const stripEmptySlots = (params: Params) => { - for (const [slot, value] of Object.entries(params)) { - if (value && typeof value === 'object' && !Object.keys(value).length) { - delete params[slot as Slot]; - } - } -}; - -export const buildClientParams = ( - args: ReadonlyArray, - fields: FieldsConfig, -) => { - const params: Params = { - body: {}, - headers: {}, - path: {}, - query: {}, - }; - - const map = buildKeyMap(fields); - - let config: FieldsConfig[number] | undefined; - - for (const [index, arg] of args.entries()) { - if (fields[index]) { - config = fields[index]; - } - - if (!config) { - continue; - } - - if ('in' in config) { - if (config.key) { - const field = map.get(config.key)!; - const name = field.map || config.key; - (params[field.in] as Record)[name] = arg; - } else { - params.body = arg; - } - } else { - for (const [key, value] of Object.entries(arg ?? {})) { - const field = map.get(key); - - if (field) { - const name = field.map || key; - (params[field.in] as Record)[name] = value; - } else { - const extra = extraPrefixes.find(([prefix]) => - key.startsWith(prefix), - ); - - if (extra) { - const [prefix, slot] = extra; - (params[slot] as Record)[ - key.slice(prefix.length) - ] = value; - } else { - for (const [slot, allowed] of Object.entries( - config.allowExtra ?? {}, - )) { - if (allowed) { - (params[slot as Slot] as Record)[key] = value; - break; - } - } - } - } - } - } - } - - stripEmptySlots(params); - - return params; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts deleted file mode 100644 index 8d9993104..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts +++ /dev/null @@ -1,181 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -interface SerializeOptions - extends SerializePrimitiveOptions, - SerializerOptions {} - -interface SerializePrimitiveOptions { - allowReserved?: boolean; - name: string; -} - -export interface SerializerOptions { - /** - * @default true - */ - explode: boolean; - style: T; -} - -export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; -export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; -type MatrixStyle = 'label' | 'matrix' | 'simple'; -export type ObjectStyle = 'form' | 'deepObject'; -type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; - -interface SerializePrimitiveParam extends SerializePrimitiveOptions { - value: string; -} - -export const separatorArrayExplode = (style: ArraySeparatorStyle) => { - switch (style) { - case 'label': - return '.'; - case 'matrix': - return ';'; - case 'simple': - return ','; - default: - return '&'; - } -}; - -export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { - switch (style) { - case 'form': - return ','; - case 'pipeDelimited': - return '|'; - case 'spaceDelimited': - return '%20'; - default: - return ','; - } -}; - -export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { - switch (style) { - case 'label': - return '.'; - case 'matrix': - return ';'; - case 'simple': - return ','; - default: - return '&'; - } -}; - -export const serializeArrayParam = ({ - allowReserved, - explode, - name, - style, - value, -}: SerializeOptions & { - value: unknown[]; -}) => { - if (!explode) { - const joinedValues = ( - allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) - ).join(separatorArrayNoExplode(style)); - switch (style) { - case 'label': - return `.${joinedValues}`; - case 'matrix': - return `;${name}=${joinedValues}`; - case 'simple': - return joinedValues; - default: - return `${name}=${joinedValues}`; - } - } - - const separator = separatorArrayExplode(style); - const joinedValues = value - .map((v) => { - if (style === 'label' || style === 'simple') { - return allowReserved ? v : encodeURIComponent(v as string); - } - - return serializePrimitiveParam({ - allowReserved, - name, - value: v as string, - }); - }) - .join(separator); - return style === 'label' || style === 'matrix' - ? separator + joinedValues - : joinedValues; -}; - -export const serializePrimitiveParam = ({ - allowReserved, - name, - value, -}: SerializePrimitiveParam) => { - if (value === undefined || value === null) { - return ''; - } - - if (typeof value === 'object') { - throw new Error( - 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', - ); - } - - return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; -}; - -export const serializeObjectParam = ({ - allowReserved, - explode, - name, - style, - value, - valueOnly, -}: SerializeOptions & { - value: Record | Date; - valueOnly?: boolean; -}) => { - if (value instanceof Date) { - return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; - } - - if (style !== 'deepObject' && !explode) { - let values: string[] = []; - Object.entries(value).forEach(([key, v]) => { - values = [ - ...values, - key, - allowReserved ? (v as string) : encodeURIComponent(v as string), - ]; - }); - const joinedValues = values.join(','); - switch (style) { - case 'form': - return `${name}=${joinedValues}`; - case 'label': - return `.${joinedValues}`; - case 'matrix': - return `;${name}=${joinedValues}`; - default: - return joinedValues; - } - } - - const separator = separatorObjectExplode(style); - const joinedValues = Object.entries(value) - .map(([key, v]) => - serializePrimitiveParam({ - allowReserved, - name: style === 'deepObject' ? `${name}[${key}]` : key, - value: v as string, - }), - ) - .join(separator); - return style === 'label' || style === 'matrix' - ? separator + joinedValues - : joinedValues; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts deleted file mode 100644 index f8fd78e28..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts +++ /dev/null @@ -1,264 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Config } from './types.gen'; - -export type ServerSentEventsOptions = Omit< - RequestInit, - 'method' -> & - Pick & { - /** - * Fetch API implementation. You can use this option to provide a custom - * fetch instance. - * - * @default globalThis.fetch - */ - fetch?: typeof fetch; - /** - * Implementing clients can call request interceptors inside this hook. - */ - onRequest?: (url: string, init: RequestInit) => Promise; - /** - * Callback invoked when a network or parsing error occurs during streaming. - * - * This option applies only if the endpoint returns a stream of events. - * - * @param error The error that occurred. - */ - onSseError?: (error: unknown) => void; - /** - * Callback invoked when an event is streamed from the server. - * - * This option applies only if the endpoint returns a stream of events. - * - * @param event Event streamed from the server. - * @returns Nothing (void). - */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; - /** - * Default retry delay in milliseconds. - * - * This option applies only if the endpoint returns a stream of events. - * - * @default 3000 - */ - sseDefaultRetryDelay?: number; - /** - * Maximum number of retry attempts before giving up. - */ - sseMaxRetryAttempts?: number; - /** - * Maximum retry delay in milliseconds. - * - * Applies only when exponential backoff is used. - * - * This option applies only if the endpoint returns a stream of events. - * - * @default 30000 - */ - sseMaxRetryDelay?: number; - /** - * Optional sleep function for retry backoff. - * - * Defaults to using `setTimeout`. - */ - sseSleepFn?: (ms: number) => Promise; - url: string; - }; - -export interface StreamEvent { - data: TData; - event?: string; - id?: string; - retry?: number; -} - -export type ServerSentEventsResult< - TData = unknown, - TReturn = void, - TNext = unknown, -> = { - stream: AsyncGenerator< - TData extends Record ? TData[keyof TData] : TData, - TReturn, - TNext - >; -}; - -export const createSseClient = ({ - onRequest, - onSseError, - onSseEvent, - responseTransformer, - responseValidator, - sseDefaultRetryDelay, - sseMaxRetryAttempts, - sseMaxRetryDelay, - sseSleepFn, - url, - ...options -}: ServerSentEventsOptions): ServerSentEventsResult => { - let lastEventId: string | undefined; - - const sleep = - sseSleepFn ?? - ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); - - const createStream = async function* () { - let retryDelay: number = sseDefaultRetryDelay ?? 3000; - let attempt = 0; - const signal = options.signal ?? new AbortController().signal; - - while (true) { - if (signal.aborted) break; - - attempt++; - - const headers = - options.headers instanceof Headers - ? options.headers - : new Headers(options.headers as Record | undefined); - - if (lastEventId !== undefined) { - headers.set('Last-Event-ID', lastEventId); - } - - try { - const requestInit: RequestInit = { - redirect: 'follow', - ...options, - body: options.serializedBody, - headers, - signal, - }; - let request = new Request(url, requestInit); - if (onRequest) { - request = await onRequest(url, requestInit); - } - // fetch must be assigned here, otherwise it would throw the error: - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation - const _fetch = options.fetch ?? globalThis.fetch; - const response = await _fetch(request); - - if (!response.ok) - throw new Error( - `SSE failed: ${response.status} ${response.statusText}`, - ); - - if (!response.body) throw new Error('No body in SSE response'); - - const reader = response.body - .pipeThrough(new TextDecoderStream()) - .getReader(); - - let buffer = ''; - - const abortHandler = () => { - try { - reader.cancel(); - } catch { - // noop - } - }; - - signal.addEventListener('abort', abortHandler); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) break; - buffer += value; - - const chunks = buffer.split('\n\n'); - buffer = chunks.pop() ?? ''; - - for (const chunk of chunks) { - const lines = chunk.split('\n'); - const dataLines: Array = []; - let eventName: string | undefined; - - for (const line of lines) { - if (line.startsWith('data:')) { - dataLines.push(line.replace(/^data:\s*/, '')); - } else if (line.startsWith('event:')) { - eventName = line.replace(/^event:\s*/, ''); - } else if (line.startsWith('id:')) { - lastEventId = line.replace(/^id:\s*/, ''); - } else if (line.startsWith('retry:')) { - const parsed = Number.parseInt( - line.replace(/^retry:\s*/, ''), - 10, - ); - if (!Number.isNaN(parsed)) { - retryDelay = parsed; - } - } - } - - let data: unknown; - let parsedJson = false; - - if (dataLines.length) { - const rawData = dataLines.join('\n'); - try { - data = JSON.parse(rawData); - parsedJson = true; - } catch { - data = rawData; - } - } - - if (parsedJson) { - if (responseValidator) { - await responseValidator(data); - } - - if (responseTransformer) { - data = await responseTransformer(data); - } - } - - onSseEvent?.({ - data, - event: eventName, - id: lastEventId, - retry: retryDelay, - }); - - if (dataLines.length) { - yield data as any; - } - } - } - } finally { - signal.removeEventListener('abort', abortHandler); - reader.releaseLock(); - } - - break; // exit loop on normal completion - } catch (error) { - // connection failed or aborted; retry after delay - onSseError?.(error); - - if ( - sseMaxRetryAttempts !== undefined && - attempt >= sseMaxRetryAttempts - ) { - break; // stop after firing error - } - - // exponential backoff: double retry each attempt, cap at 30s - const backoff = Math.min( - retryDelay * 2 ** (attempt - 1), - sseMaxRetryDelay ?? 30000, - ); - await sleep(backoff); - } - } - }; - - const stream = createStream(); - - return { stream }; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts deleted file mode 100644 index 643c070c9..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts +++ /dev/null @@ -1,118 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Auth, AuthToken } from './auth.gen'; -import type { - BodySerializer, - QuerySerializer, - QuerySerializerOptions, -} from './bodySerializer.gen'; - -export type HttpMethod = - | 'connect' - | 'delete' - | 'get' - | 'head' - | 'options' - | 'patch' - | 'post' - | 'put' - | 'trace'; - -export type Client< - RequestFn = never, - Config = unknown, - MethodFn = never, - BuildUrlFn = never, - SseFn = never, -> = { - /** - * Returns the final request URL. - */ - buildUrl: BuildUrlFn; - getConfig: () => Config; - request: RequestFn; - setConfig: (config: Config) => Config; -} & { - [K in HttpMethod]: MethodFn; -} & ([SseFn] extends [never] - ? { sse?: never } - : { sse: { [K in HttpMethod]: SseFn } }); - -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; - /** - * A function for serializing request body parameter. By default, - * {@link JSON.stringify()} will be used. - */ - bodySerializer?: BodySerializer | null; - /** - * An object containing any HTTP headers that you want to pre-populate your - * `Headers` object with. - * - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} - */ - headers?: - | RequestInit['headers'] - | Record< - string, - | string - | number - | boolean - | (string | number | boolean)[] - | null - | undefined - | unknown - >; - /** - * The request method. - * - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} - */ - method?: Uppercase; - /** - * A function for serializing request query parameters. By default, arrays - * will be exploded in form style, objects will be exploded in deepObject - * style, and reserved characters are percent-encoded. - * - * This method will have no effect if the native `paramsSerializer()` Axios - * API function is used. - * - * {@link https://swagger.io/docs/specification/serialization/#query View examples} - */ - querySerializer?: QuerySerializer | QuerySerializerOptions; - /** - * 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; - /** - * 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; - /** - * 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; -} - -type IsExactlyNeverOrNeverUndefined = [T] extends [never] - ? true - : [T] extends [never | undefined] - ? [undefined] extends [T] - ? false - : true - : false; - -export type OmitNever> = { - [K in keyof T as IsExactlyNeverOrNeverUndefined extends true - ? never - : K]: T[K]; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts deleted file mode 100644 index ac31396fe..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts +++ /dev/null @@ -1,114 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { QuerySerializer } from './bodySerializer.gen'; -import { - type ArraySeparatorStyle, - serializeArrayParam, - serializeObjectParam, - serializePrimitiveParam, -} from './pathSerializer.gen'; - -export interface PathSerializer { - path: Record; - url: string; -} - -export const PATH_PARAM_RE = /\{[^{}]+\}/g; - -export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { - let url = _url; - const matches = _url.match(PATH_PARAM_RE); - if (matches) { - for (const match of matches) { - let explode = false; - let name = match.substring(1, match.length - 1); - let style: ArraySeparatorStyle = 'simple'; - - if (name.endsWith('*')) { - explode = true; - name = name.substring(0, name.length - 1); - } - - if (name.startsWith('.')) { - name = name.substring(1); - style = 'label'; - } else if (name.startsWith(';')) { - name = name.substring(1); - style = 'matrix'; - } - - const value = path[name]; - - if (value === undefined || value === null) { - continue; - } - - if (Array.isArray(value)) { - url = url.replace( - match, - serializeArrayParam({ explode, name, style, value }), - ); - continue; - } - - if (typeof value === 'object') { - url = url.replace( - match, - serializeObjectParam({ - explode, - name, - style, - value: value as Record, - valueOnly: true, - }), - ); - continue; - } - - if (style === 'matrix') { - url = url.replace( - match, - `;${serializePrimitiveParam({ - name, - value: value as string, - })}`, - ); - continue; - } - - const replaceValue = encodeURIComponent( - style === 'label' ? `.${value as string}` : (value as string), - ); - url = url.replace(match, replaceValue); - } - } - return url; -}; - -export const getUrl = ({ - baseUrl, - path, - query, - querySerializer, - url: _url, -}: { - baseUrl?: string; - path?: Record; - query?: Record; - querySerializer: QuerySerializer; - url: string; -}) => { - const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; - let url = (baseUrl ?? '') + pathUrl; - if (path) { - url = defaultPathSerializer({ path, url }); - } - let search = query ? querySerializer(query) : ''; - if (search.startsWith('?')) { - search = search.substring(1); - } - if (search) { - url += `?${search}`; - } - return url; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/index.ts deleted file mode 100644 index e64537d21..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts deleted file mode 100644 index 836b0ecb6..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts +++ /dev/null @@ -1,277 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Options as ClientOptions, TDataShape, Client } from './client'; -import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; - -export type Options = ClientOptions & { - /** - * You can provide a client instance returned by `createClient()` instead of - * individual options. This might be also useful if you want to implement a - * custom client. - */ - client?: Client; - /** - * You can pass arbitrary values through the `meta` object. This can be - * used to access values that aren't defined as part of the SDK function. - */ - meta?: Record; -}; - -export const serviceWithEmptyTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/descriptions/', - ...options - }); -}; - -export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/{parameterPath}', - ...options - }); -}; - -export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', - ...options - }); -}; - -export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/no-content', - ...options - }); -}; - -export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/response-and-no-content', - ...options - }); -}; - -export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/a', - ...options - }); -}; - -export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/b', - ...options - }); -}; - -export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - querySerializer: { - array: { - explode: false, - style: 'form' - } - }, - url: '/api/v{api-version}/collectionFormat', - ...options - }); -}; - -export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - querySerializer: { - array: { - explode: false, - style: 'form' - } - }, - url: '/api/v{api-version}/types', - ...options - }); -}; - -export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/complex', - ...options - }); -}; - -export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/header', - ...options - }); -}; - -export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/error', - ...options - }); -}; - -export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', - ...options - }); -}; - -/** - * Body should not be unknown - * Body should not be unknown - */ -export const postApiVbyApiVersionBody = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/body', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts deleted file mode 100644 index 1fade89b2..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts +++ /dev/null @@ -1,1179 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; - -export type ExternalRefB = ExternalRefA; - -/** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ -export type CommentWithBreaks = number; - -/** - * Testing backticks in string: `backticks` and ```multiple backticks``` should work - */ -export type CommentWithBackticks = number; - -/** - * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work - */ -export type CommentWithBackticksAndQuotes = number; - -/** - * Testing slashes in string: \backwards\\\ and /forwards/// should work - */ -export type CommentWithSlashes = number; - -/** - * Testing expression placeholders in string: ${expression} should work - */ -export type CommentWithExpressionPlaceholders = number; - -/** - * Testing quotes in string: 'single quote''' and "double quotes""" should work - */ -export type CommentWithQuotes = number; - -/** - * Testing reserved characters in string: * inline * and ** inline ** should work - */ -export type CommentWithReservedCharacters = number; - -/** - * This is a simple number - */ -export type SimpleInteger = number; - -/** - * This is a simple boolean - */ -export type SimpleBoolean = boolean; - -/** - * This is a simple string - */ -export type SimpleString = string; - -/** - * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) - */ -export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; - -/** - * This is a simple file - */ -export type SimpleFile = Blob | File; - -export type SimpleReference = ModelWithString; - -/** - * This is a simple string - */ -export type SimpleStringWithPattern = string; - -/** - * This is a simple enum with strings - */ -export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; - -/** - * This is a simple enum with numbers - */ -export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; - -/** - * Success=1,Warning=2,Error=3 - */ -export type EnumFromDescription = number; - -/** - * This is a simple enum with numbers - */ -export type EnumWithExtensions = 200 | 400 | 500; - -/** - * This is a simple array with numbers - */ -export type ArrayWithNumbers = Array; - -/** - * This is a simple array with booleans - */ -export type ArrayWithBooleans = Array; - -/** - * This is a simple array with strings - */ -export type ArrayWithStrings = Array; - -/** - * This is a simple array with references - */ -export type ArrayWithReferences = Array; - -/** - * This is a simple array containing an array - */ -export type ArrayWithArray = Array>; - -/** - * This is a simple array with properties - */ -export type ArrayWithProperties = Array<{ - foo?: string; - bar?: string; -}>; - -/** - * This is a string dictionary - */ -export type DictionaryWithString = { - [key: string]: string; -}; - -/** - * This is a string reference - */ -export type DictionaryWithReference = { - [key: string]: ModelWithString; -}; - -/** - * This is a complex dictionary - */ -export type DictionaryWithArray = { - [key: string]: Array; -}; - -/** - * This is a string dictionary - */ -export type DictionaryWithDictionary = { - [key: string]: { - [key: string]: string; - }; -}; - -/** - * This is a complex dictionary - */ -export type DictionaryWithProperties = { - [key: string]: { - foo?: string; - bar?: string; - }; -}; - -/** - * This is a type-only model that defines Date as a string - */ -export type _Date = string; - -/** - * This is a model with one number property - */ -export type ModelWithInteger = { - /** - * This is a simple number property - */ - prop?: number; -}; - -/** - * This is a model with one boolean property - */ -export type ModelWithBoolean = { - /** - * This is a simple boolean property - */ - prop?: boolean; -}; - -/** - * This is a model with one string property - */ -export type ModelWithString = { - /** - * This is a simple string property - */ - prop?: string; -}; - -/** - * This is a model with one string property - */ -export type ModelWithStringError = { - /** - * This is a simple string property - */ - prop?: string; -}; - -/** - * This is a model with one string property - */ -export type ModelWithNullableString = { - /** - * This is a simple string property - */ - nullableProp?: string | null; - /** - * This is a simple string property - */ - nullableRequiredProp: string | null; -}; - -/** - * This is a model with one enum - */ -export type ModelWithEnum = { - /** - * This is a simple enum with strings - */ - test?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; - /** - * These are the HTTP error code enums - */ - statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; - /** - * Simple boolean enum - */ - bool?: true; -}; - -/** - * This is a model with one enum - */ -export type ModelWithEnumFromDescription = { - /** - * Success=1,Warning=2,Error=3 - */ - test?: number; -}; - -/** - * This is a model with nested enums - */ -export type ModelWithNestedEnums = { - dictionaryWithEnum?: { - [key: string]: 'Success' | 'Warning' | 'Error'; - }; - dictionaryWithEnumFromDescription?: { - [key: string]: number; - }; - arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; - arrayWithDescription?: Array; -}; - -/** - * This is a model with one property containing a reference - */ -export type ModelWithReference = { - prop?: ModelWithProperties; -}; - -/** - * This is a model with one property containing an array - */ -export type ModelWithArray = { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -}; - -/** - * This is a model with one property containing a dictionary - */ -export type ModelWithDictionary = { - prop?: { - [key: string]: string; - }; -}; - -/** - * This is a model with one property containing a circular reference - */ -export type ModelWithCircularReference = { - prop?: ModelWithCircularReference; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithProperties = { - required: string; - readonly requiredAndReadOnly: string; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithNestedProperties = { - readonly first: { - readonly second: { - readonly third: string; - }; - }; -}; - -/** - * This is a model with duplicated properties - */ -export type ModelWithDuplicateProperties = { - prop?: ModelWithString; -}; - -/** - * This is a model with ordered properties - */ -export type ModelWithOrderedProperties = { - zebra?: string; - apple?: string; - hawaii?: string; -}; - -/** - * This is a model with duplicated imports - */ -export type ModelWithDuplicateImports = { - propA?: ModelWithString; - propB?: ModelWithString; - propC?: ModelWithString; -}; - -/** - * This is a model that extends another model - */ -export type ModelThatExtends = ModelWithString & { - propExtendsA?: string; - propExtendsB?: ModelWithString; -}; - -/** - * This is a model that extends another model - */ -export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { - propExtendsC?: string; - propExtendsD?: ModelWithString; -}; - -export type Default = { - name?: string; -}; - -/** - * This is a model that contains a some patterns - */ -export type ModelWithPattern = { - key: string; - name: string; - readonly enabled?: boolean; - readonly modified?: string; - id?: string; - text?: string; - patternWithSingleQuotes?: string; - patternWithNewline?: string; - patternWithBacktick?: string; -}; - -export type ParameterActivityParams = { - description?: string; - graduate_id?: number; - organization_id?: number; - parent_activity?: number; - post_id?: number; -}; - -export type ResponsePostActivityResponse = { - description?: string; - graduate_id?: number; - organization_id?: number; - parent_activity_id?: number; - post_id?: number; -}; - -export type FailureFailure = { - error?: string; - message?: string; - reference_code?: string; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithPropertiesWritable = { - required: string; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; -}; - -/** - * This is a model that contains a some patterns - */ -export type ModelWithPatternWritable = { - key: string; - name: string; - id?: string; - text?: string; - patternWithSingleQuotes?: string; - patternWithNewline?: string; - patternWithBacktick?: string; -}; - -export type ServiceWithEmptyTagData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type PatchApiVbyApiVersionNoTagData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type PatchApiVbyApiVersionNoTagResponses = { - /** - * OK - */ - default: unknown; -}; - -export type FooWowData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type FooWowResponses = { - /** - * OK - */ - default: unknown; -}; - -export type DeleteCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type GetCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type HeadCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type OptionsCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PatchCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PostCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PutCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type CallWithDescriptionsData = { - body?: never; - path?: never; - query?: { - /** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ - parameterWithBreaks?: string; - /** - * Testing backticks in string: `backticks` and ```multiple backticks``` should work - */ - parameterWithBackticks?: string; - /** - * Testing slashes in string: \backwards\\\ and /forwards/// should work - */ - parameterWithSlashes?: string; - /** - * Testing expression placeholders in string: ${expression} should work - */ - parameterWithExpressionPlaceholders?: string; - /** - * Testing quotes in string: 'single quote''' and "double quotes""" should work - */ - parameterWithQuotes?: string; - /** - * Testing reserved characters in string: * inline * and ** inline ** should work - */ - parameterWithReservedCharacters?: string; - }; - url: '/api/v{api-version}/descriptions/'; -}; - -export type CallWithParametersData = { - body?: never; - headers: { - /** - * This is the parameter that goes into the header - */ - parameterHeader: string; - }; - path: { - /** - * This is the parameter that goes into the path - */ - parameterPath: string; - /** - * api-version should be required in standalone clients - */ - 'api-version': string; - }; - query: { - /** - * This is the parameter that goes into the query params - */ - parameterQuery: string; - }; - url: '/api/v{api-version}/parameters/{parameterPath}'; -}; - -export type CallWithWeirdParameterNamesData = { - body?: never; - headers: { - /** - * This is the parameter that goes into the request header - */ - 'parameter.header': string; - }; - path: { - /** - * This is the parameter that goes into the path - */ - 'parameter.path.1'?: string; - /** - * This is the parameter that goes into the path - */ - 'parameter-path-2'?: string; - /** - * This is the parameter that goes into the path - */ - 'PARAMETER-PATH-3'?: string; - /** - * api-version should be required in standalone clients - */ - 'api-version': string; - }; - query: { - /** - * This is the parameter with a reserved keyword - */ - default?: string; - /** - * This is the parameter that goes into the request query params - */ - 'parameter-query': string; - }; - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; -}; - -export type CallWithDefaultParametersData = { - body?: never; - path?: never; - query: { - /** - * This is a simple string with default value - */ - parameterString: string; - /** - * This is a simple number with default value - */ - parameterNumber: number; - /** - * This is a simple boolean with default value - */ - parameterBoolean: boolean; - /** - * This is a simple enum with default value - */ - parameterEnum: 'Success' | 'Warning' | 'Error'; - /** - * This is a model with one string property - */ - parameterModel: { - /** - * This is a simple string property - */ - prop?: string; - }; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type CallWithDefaultOptionalParametersData = { - body?: never; - path?: never; - query?: { - /** - * This is a simple string that is optional with default value - */ - parameterString?: string; - /** - * This is a simple number that is optional with default value - */ - parameterNumber?: number; - /** - * This is a simple boolean that is optional with default value - */ - parameterBoolean?: boolean; - /** - * This is a simple enum that is optional with default value - */ - parameterEnum?: 'Success' | 'Warning' | 'Error'; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type CallToTestOrderOfParamsData = { - body?: never; - path?: never; - query: { - /** - * This is a optional string with default - */ - parameterOptionalStringWithDefault?: string; - /** - * This is a optional string with empty default - */ - parameterOptionalStringWithEmptyDefault?: string; - /** - * This is a optional string with no default - */ - parameterOptionalStringWithNoDefault?: string; - /** - * This is a string with default - */ - parameterStringWithDefault: string; - /** - * This is a string with empty default - */ - parameterStringWithEmptyDefault: string; - /** - * This is a string with no default - */ - parameterStringWithNoDefault: string; - /** - * This is a string that can be null with no default - */ - parameterStringNullableWithNoDefault?: string | null; - /** - * This is a string that can be null with default - */ - parameterStringNullableWithDefault?: string | null; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type DuplicateNameData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName2Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName3Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName4Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type CallWithNoContentResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no-content'; -}; - -export type CallWithNoContentResponseResponses = { - /** - * Success - */ - 204: unknown; -}; - -export type CallWithResponseAndNoContentResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/response-and-no-content'; -}; - -export type CallWithResponseAndNoContentResponseResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Success - */ - 204: unknown; -}; - -export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; - -export type DummyAData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/a'; -}; - -export type DummyAResponses = { - /** - * Success - */ - 204: unknown; -}; - -export type DummyBData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/b'; -}; - -export type DummyBResponses = { - /** - * Success - */ - 204: unknown; -}; - -export type CallWithResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithResponseResponses = { - /** - * Message for default response - */ - default: ModelWithString; -}; - -export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; - -export type CallWithDuplicateResponsesData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithDuplicateResponsesErrors = { - /** - * Message for 500 error - */ - 500: ModelWithStringError; - /** - * Message for 501 error - */ - 501: ModelWithStringError; - /** - * Message for 502 error - */ - 502: ModelWithStringError; - /** - * Message for default response - */ - default: ModelWithString; -}; - -export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; - -export type CallWithDuplicateResponsesResponses = { - /** - * Message for 201 response - */ - 201: ModelWithString; - /** - * Message for 202 response - */ - 202: ModelWithString; -}; - -export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; - -export type CallWithResponsesData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithResponsesErrors = { - /** - * Message for 500 error - */ - 500: ModelWithStringError; - /** - * Message for 501 error - */ - 501: ModelWithStringError; - /** - * Message for 502 error - */ - 502: ModelWithStringError; - /** - * Message for default response - */ - default: ModelWithString; -}; - -export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; - -export type CallWithResponsesResponses = { - /** - * Message for 200 response - */ - 200: { - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; - readonly value?: Array; - }; - /** - * Message for 201 response - */ - 201: ModelThatExtends; - /** - * Message for 202 response - */ - 202: ModelThatExtendsExtends; -}; - -export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; - -export type CollectionFormatData = { - body?: never; - path?: never; - query: { - /** - * This is an array parameter that is sent as csv format (comma-separated values) - */ - parameterArrayCSV: Array; - /** - * This is an array parameter that is sent as ssv format (space-separated values) - */ - parameterArraySSV: Array; - /** - * This is an array parameter that is sent as tsv format (tab-separated values) - */ - parameterArrayTSV: Array; - /** - * This is an array parameter that is sent as pipes format (pipe-separated values) - */ - parameterArrayPipes: Array; - /** - * This is an array parameter that is sent as multi format (multiple parameter instances) - */ - parameterArrayMulti: Array; - }; - url: '/api/v{api-version}/collectionFormat'; -}; - -export type TypesData = { - body?: never; - path?: { - /** - * This is a number parameter - */ - id?: number; - }; - query: { - /** - * This is a number parameter - */ - parameterNumber: number; - /** - * This is a string parameter - */ - parameterString: string; - /** - * This is a boolean parameter - */ - parameterBoolean: boolean; - /** - * This is an array parameter - */ - parameterArray: Array; - /** - * This is a dictionary parameter - */ - parameterDictionary: { - [key: string]: unknown; - }; - /** - * This is an enum parameter - */ - parameterEnum: 'Success' | 'Warning' | 'Error'; - }; - url: '/api/v{api-version}/types'; -}; - -export type TypesResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Response is a simple string - */ - 201: string; - /** - * Response is a simple boolean - */ - 202: boolean; - /** - * Response is a simple object - */ - 203: { - [key: string]: unknown; - }; -}; - -export type TypesResponse = TypesResponses[keyof TypesResponses]; - -export type ComplexTypesData = { - body?: never; - path?: never; - query: { - /** - * Parameter containing object - */ - parameterObject: { - first?: { - second?: { - third?: string; - }; - }; - }; - /** - * This is a model with one string property - */ - parameterReference: { - /** - * This is a simple string property - */ - prop?: string; - }; - }; - url: '/api/v{api-version}/complex'; -}; - -export type ComplexTypesErrors = { - /** - * 400 server error - */ - 400: unknown; - /** - * 500 server error - */ - 500: unknown; -}; - -export type ComplexTypesResponses = { - /** - * Successful response - */ - 200: Array; -}; - -export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; - -export type CallWithResultFromHeaderData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/header'; -}; - -export type CallWithResultFromHeaderErrors = { - /** - * 400 server error - */ - 400: unknown; - /** - * 500 server error - */ - 500: unknown; -}; - -export type CallWithResultFromHeaderResponses = { - /** - * Successful response - */ - 200: unknown; -}; - -export type TestErrorCodeData = { - body?: never; - path?: never; - query: { - /** - * Status code to return - */ - status: string; - }; - url: '/api/v{api-version}/error'; -}; - -export type TestErrorCodeErrors = { - /** - * Custom message: Internal Server Error - */ - 500: unknown; - /** - * Custom message: Not Implemented - */ - 501: unknown; - /** - * Custom message: Bad Gateway - */ - 502: unknown; - /** - * Custom message: Service Unavailable - */ - 503: unknown; -}; - -export type TestErrorCodeResponses = { - /** - * Custom message: Successful response - */ - 200: unknown; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Data = { - body?: never; - path?: never; - query: { - /** - * Dummy input param - */ - nonAsciiParamæøåÆØÅöôêÊ: number; - }; - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { - /** - * Successful response - */ - 200: NonAsciiStringæøåÆøÅöôêÊ字符串; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; - -export type PostApiVbyApiVersionBodyData = { - /** - * Body should not be unknown - */ - body: ParameterActivityParams; - path?: never; - query?: never; - url: '/api/v{api-version}/body'; -}; - -export type PostApiVbyApiVersionBodyErrors = { - /** - * Bad Request - */ - 400: FailureFailure; - /** - * Internal Server Error - */ - 500: FailureFailure; -}; - -export type PostApiVbyApiVersionBodyError = PostApiVbyApiVersionBodyErrors[keyof PostApiVbyApiVersionBodyErrors]; - -export type PostApiVbyApiVersionBodyResponses = { - /** - * OK - */ - 200: ResponsePostActivityResponse; -}; - -export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses[keyof PostApiVbyApiVersionBodyResponses]; - -export type ClientOptions = { - baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts index 541563521..2c34871f1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts index 6330689ec..5edad337f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts @@ -4,7 +4,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -527,4 +527,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts index 467d93673..84d57fda4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,147 +19,147 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/no-content', ...options @@ -167,7 +167,7 @@ export const callWithNoContentResponse = ( }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -175,7 +175,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -183,7 +183,7 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/b', ...options @@ -191,14 +191,14 @@ export const dummyB = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -206,7 +206,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -214,7 +214,7 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -227,7 +227,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -241,7 +241,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -249,7 +249,7 @@ export const complexTypes = (options: Opti }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/header', ...options @@ -257,7 +257,7 @@ export const callWithResultFromHeader = (o }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/error', ...options @@ -265,7 +265,7 @@ export const testErrorCode = (options: Opt }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -277,7 +277,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/body', ...options, @@ -286,4 +286,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index 4a1834d8b..15255213f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts index 2a449d44e..8d3bdd514 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts @@ -3,7 +3,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, callWithDescriptions, callWithParameters, callWithWeirdParameterNames, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, complexTypes, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, postApiVbyApiVersionBody } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -526,4 +526,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts index 836b0ecb6..b215924fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts index 0b3f03acd..cc71b7997 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts index abb85ef9a..45e48e977 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Us } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts index 581b8af82..8f1ad7c35 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts @@ -4,7 +4,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -527,4 +527,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts index 467d93673..84d57fda4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,147 +19,147 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/no-content', ...options @@ -167,7 +167,7 @@ export const callWithNoContentResponse = ( }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -175,7 +175,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -183,7 +183,7 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/b', ...options @@ -191,14 +191,14 @@ export const dummyB = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -206,7 +206,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -214,7 +214,7 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -227,7 +227,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -241,7 +241,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -249,7 +249,7 @@ export const complexTypes = (options: Opti }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/header', ...options @@ -257,7 +257,7 @@ export const callWithResultFromHeader = (o }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/error', ...options @@ -265,7 +265,7 @@ export const testErrorCode = (options: Opt }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -277,7 +277,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/body', ...options, @@ -286,4 +286,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts index 4a1834d8b..15255213f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts index f6686fcfb..244f7d8d0 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, callWithDescriptions, callWithParameters, callWithWeirdParameterNames, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, complexTypes, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, postApiVbyApiVersionBody } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -526,4 +526,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts index 836b0ecb6..b215924fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts index 497cf4d39..80cf0ec00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): UseMutati } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts index c5f84b545..893e5f52d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts index 63c46a966..88d9a436a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts @@ -4,7 +4,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -527,4 +527,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts index 467d93673..84d57fda4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,147 +19,147 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/no-content', ...options @@ -167,7 +167,7 @@ export const callWithNoContentResponse = ( }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -175,7 +175,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -183,7 +183,7 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/b', ...options @@ -191,14 +191,14 @@ export const dummyB = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -206,7 +206,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -214,7 +214,7 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -227,7 +227,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -241,7 +241,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -249,7 +249,7 @@ export const complexTypes = (options: Opti }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/header', ...options @@ -257,7 +257,7 @@ export const callWithResultFromHeader = (o }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/error', ...options @@ -265,7 +265,7 @@ export const testErrorCode = (options: Opt }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -277,7 +277,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/body', ...options, @@ -286,4 +286,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts index 4a1834d8b..15255213f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts index 17f8bbcce..e3d114c97 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, callWithDescriptions, callWithParameters, callWithWeirdParameterNames, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, complexTypes, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, postApiVbyApiVersionBody } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -526,4 +526,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts index 836b0ecb6..b215924fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts index 60c022a12..392d84621 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts index dea24b56c..1086c2202 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts index cffffd81f..927760423 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts @@ -4,7 +4,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -527,4 +527,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts index 467d93673..84d57fda4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,147 +19,147 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/no-content', ...options @@ -167,7 +167,7 @@ export const callWithNoContentResponse = ( }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -175,7 +175,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -183,7 +183,7 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/b', ...options @@ -191,14 +191,14 @@ export const dummyB = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -206,7 +206,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -214,7 +214,7 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -227,7 +227,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -241,7 +241,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -249,7 +249,7 @@ export const complexTypes = (options: Opti }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/header', ...options @@ -257,7 +257,7 @@ export const callWithResultFromHeader = (o }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/error', ...options @@ -265,7 +265,7 @@ export const testErrorCode = (options: Opt }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -277,7 +277,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/body', ...options, @@ -286,4 +286,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index 4a1834d8b..15255213f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts index 80aadd388..70f5b99be 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, callWithDescriptions, callWithParameters, callWithWeirdParameterNames, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, complexTypes, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, postApiVbyApiVersionBody } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -526,4 +526,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts index 836b0ecb6..b215924fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts index 6e7ff65de..98f162beb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts index e36dbe8a8..6c866b7bf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Us } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts index 99de18a61..bf63c8f5b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts @@ -4,7 +4,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -527,4 +527,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts index 467d93673..84d57fda4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,147 +19,147 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/no-content', ...options @@ -167,7 +167,7 @@ export const callWithNoContentResponse = ( }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -175,7 +175,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -183,7 +183,7 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/b', ...options @@ -191,14 +191,14 @@ export const dummyB = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -206,7 +206,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -214,7 +214,7 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -227,7 +227,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -241,7 +241,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -249,7 +249,7 @@ export const complexTypes = (options: Opti }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/header', ...options @@ -257,7 +257,7 @@ export const callWithResultFromHeader = (o }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/error', ...options @@ -265,7 +265,7 @@ export const testErrorCode = (options: Opt }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -277,7 +277,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/body', ...options, @@ -286,4 +286,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts index 4a1834d8b..15255213f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts index 0e20ec2d2..0eef4016f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, serviceWithEmptyTag, patchApiVbyApiVersionNoTag, fooWow, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, callWithDescriptions, callWithParameters, callWithWeirdParameterNames, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, complexTypes, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, postApiVbyApiVersionBody } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyError, PostApiVbyApiVersionBodyResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -526,4 +526,4 @@ export const postApiVbyApiVersionBodyMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts index 836b0ecb6..b215924fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,196 +19,196 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions/', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options }); }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options }); }; export const callWithDefaultParameters = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -221,7 +221,7 @@ export const collectionFormat = (options: }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ querySerializer: { array: { explode: false, @@ -234,28 +234,28 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -266,7 +266,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/body', ...options, headers: { @@ -274,4 +274,4 @@ export const postApiVbyApiVersionBody = (o ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts index b15071c1c..463216f2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): UseMutati } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts index 314be14d3..28d798a00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/fastify.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/fastify.gen.ts index 9edc94612..b131cb6ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/fastify.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/fastify.gen.ts @@ -71,4 +71,4 @@ export type RouteHandlers = { Body: PostApiVbyApiVersionBodyData['body']; Reply: PostApiVbyApiVersionBodyErrors & PostApiVbyApiVersionBodyResponses; }>; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts index 1fade89b2..282f00886 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts @@ -1176,4 +1176,4 @@ export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts index b9012d647..0eacb3ac9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts @@ -782,4 +782,4 @@ export const vPostApiVbyApiVersionBodyData = v.object({ /** * OK */ -export const vPostApiVbyApiVersionBodyResponse = vResponsePostActivityResponse; \ No newline at end of file +export const vPostApiVbyApiVersionBodyResponse = vResponsePostActivityResponse; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/sdk.gen.ts index ebec37f4c..e5bff5c84 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { SendEmailData, SendEmailResponses, SendEmailErrors } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,7 +22,7 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/email', ...options, headers: { @@ -30,4 +30,4 @@ export const sendEmail = (options: Options ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/types.gen.ts index fcf50280e..a31ef7865 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/types.gen.ts @@ -133,4 +133,4 @@ export type SendEmailResponse2 = SendEmailResponses[keyof SendEmailResponses]; export type ClientOptions = { baseUrl: `${string}://api.postmarkapp.com` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/sdk.gen.ts index 26d9c8a24..abeb3e1f8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { in: 'query', @@ -30,4 +30,4 @@ export const getFoo = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/sdk.gen.ts index c6fc55480..6293e99d6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'basic', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/sdk.gen.ts index 02b1b6f72..5f3be6607 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,8 +19,8 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/types.gen.ts index a53fefa03..47a6dbbce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/types.gen.ts @@ -16,4 +16,4 @@ export type GetFooResponses = { export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/sdk.gen.ts index efd68f39a..8e5659281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'bearer', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = export const client = createClient(createConfig({ baseUrl: '/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/types.gen.ts index 6906f1774..7e1ba4007 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}/v1` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/types.gen.ts index b39de6295..85dba01eb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: `${string}://foo.com` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client.gen.ts index db0b4291b..53f8b2177 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'https://foo.com/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/types.gen.ts index 499949960..43d939745 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: 'https://foo.com/v1' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/types.gen.ts index 81ddb615b..9db142760 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/types.gen.ts @@ -58,4 +58,4 @@ export type PostFooReadResponse = PostFooReadResponses[keyof PostFooReadResponse export type ClientOptions = { baseUrl: string; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts index 2b1ed5a9d..d90f5b3af 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts @@ -12,4 +12,4 @@ export type Baz = Foo & { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts index 0e69f8bf4..d67d3d123 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-true/types.gen.ts @@ -20,4 +20,4 @@ export type Qux = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/types.gen.ts index cb1ed0592..1097aeb99 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-undefined/types.gen.ts @@ -8,4 +8,4 @@ export type Foo = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/types.gen.ts index b133cfb1a..4ac068762 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/types.gen.ts @@ -8,4 +8,4 @@ export type Bar = string; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/valibot.gen.ts index d59c59ed3..46cf09131 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/valibot.gen.ts @@ -6,4 +6,4 @@ export const vBar = v.string(); export const vFoo = v.object({ foo: v.optional(v.pipe(v.array(vBar), v.minLength(1), v.maxLength(2147483647))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/types.gen.ts index be12c3e29..6a8c31d0a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-nested-one-of/types.gen.ts @@ -13,4 +13,4 @@ export type Foo = Array<{ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/sdk.gen.ts index 886e60b1d..d0712e097 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ bodySerializer: null, url: '/foo', ...options, @@ -28,4 +28,4 @@ export const postFoo = (options: Options

= (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/sdk.gen.ts index 9f081dd3e..f9331f0a1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,9 +19,9 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/types.gen.ts index 7a4d43642..a2e7d5433 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseURL: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts index 5ea22ca04..3bd1045c3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-all-of/types.gen.ts @@ -64,4 +64,4 @@ export type QuxExtend = FooUnion; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/types.gen.ts index 77b8b2695..a3d6081eb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-any-of/types.gen.ts @@ -29,4 +29,4 @@ export type Quuz = ({ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/types.gen.ts index 5e54fdd48..885b1c7d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-mapped-many/types.gen.ts @@ -22,4 +22,4 @@ export type Spæcial = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/types.gen.ts index 2604947ad..73005d217 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/discriminator-one-of/types.gen.ts @@ -29,4 +29,4 @@ export type Quuz = ({ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/types.gen.ts index d3fff794b..db360dbbd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-escape/types.gen.ts @@ -8,4 +8,4 @@ export type Bar = "foo'bar" | 'foo"bar'; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/types.gen.ts index 42a789069..5ae81db36 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-javascript/types.gen.ts @@ -13,4 +13,4 @@ export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/types.gen.ts index f7118d69d..980626acc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline-typescript/types.gen.ts @@ -11,4 +11,4 @@ export enum TypeEnum { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/types.gen.ts index f0d021719..c1d043ba0 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-inline/types.gen.ts @@ -8,4 +8,4 @@ export type TypeEnum = 'foo' | 'bar'; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/types.gen.ts index c52d5cecb..ed1eac27a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-PascalCase/types.gen.ts @@ -53,4 +53,4 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts index b96d4b64f..a0ada44fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts @@ -53,4 +53,4 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/types.gen.ts index 0e0bc9ed5..6c76ad876 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-camelCase/types.gen.ts @@ -53,4 +53,4 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/types.gen.ts index 7d1be6ca4..a3452042d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-ignore-null/types.gen.ts @@ -52,4 +52,4 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/types.gen.ts index 3725400a8..b4fdbac56 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-preserve/types.gen.ts @@ -53,4 +53,4 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/types.gen.ts index bca6fc1c1..30d55e299 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-javascript-snake_case/types.gen.ts @@ -53,4 +53,4 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/types.gen.ts index 0f40354f8..d8b9e50d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-PascalCase/types.gen.ts @@ -36,4 +36,4 @@ export type Arrays = [ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts index 4ba614e18..c25efe013 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts @@ -36,4 +36,4 @@ export type Arrays = [ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/types.gen.ts index c827d76b2..48930e998 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-camelCase/types.gen.ts @@ -36,4 +36,4 @@ export type Arrays = [ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/types.gen.ts index 4b352a5e9..c99c71642 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-const/types.gen.ts @@ -36,4 +36,4 @@ export type Arrays = [ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/types.gen.ts index 556653ea3..95af7e0f2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-preserve/types.gen.ts @@ -36,4 +36,4 @@ export type Arrays = [ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/types.gen.ts index d319901f1..ece8dbc8d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values-typescript-snake_case/types.gen.ts @@ -36,4 +36,4 @@ export type Arrays = [ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/types.gen.ts index ba3f64f9a..7c6cf43ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-names-values/types.gen.ts @@ -20,4 +20,4 @@ export type Arrays = [ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/types.gen.ts index 48d0f83a2..0f113e601 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/types.gen.ts @@ -8,4 +8,4 @@ export type Baz = 'foo' | 'bar'; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts index 2e0cabb78..cbaae04e1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/valibot.gen.ts @@ -15,4 +15,4 @@ export const vBar = v.picklist([ export const vBaz = v.picklist([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/types.gen.ts index f09b2f30d..29f6d3874 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/exclude-deprecated/types.gen.ts @@ -18,4 +18,4 @@ export type PostFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/@tanstack/react-query.gen.ts index f64ca9442..3e8c2dc31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, create, create2, create3 } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { CreateData, Create2Data, Create3Data } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -83,4 +83,4 @@ export const create3Mutation = (options?: Partial>): UseMut } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/sdk.gen.ts index f80a3ecf7..095925019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { CreateData, CreateResponses, Create2Data, Create2Responses, Create3Data, Create3Responses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,22 +19,22 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const create2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/foo', ...options }); }; export const create3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/types.gen.ts index b50eb8e01..3b84b928c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/types.gen.ts @@ -44,4 +44,4 @@ export type Create3Responses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/types.gen.ts index 0250e75aa..c8043dbaa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/operation-204/types.gen.ts @@ -22,4 +22,4 @@ export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/sdk.gen.ts index 4bbb627bc..c968befbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ querySerializer: { array: { explode: false, @@ -29,4 +29,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/types.gen.ts index e1ed1030b..4639723fb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/types.gen.ts @@ -18,4 +18,4 @@ export type PostFooResponses = { export type ClientOptions = { baseURL: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/sdk.gen.ts index 4bbb627bc..c968befbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ querySerializer: { array: { explode: false, @@ -29,4 +29,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/types.gen.ts index d69993ad2..7e5ae0357 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/types.gen.ts @@ -18,4 +18,4 @@ export type PostFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts index fae644c0c..e28017eaf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts index 005a668e0..2d5985b31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options = export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts index dd1bb7d5b..4ff334ff7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,21 +20,21 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/business/providers/domains', ...options }); } public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/business/providers/domains', ...options }); } public static putBusinessProvidersDomains(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/business/providers/domains', ...options }); @@ -47,7 +47,7 @@ class Providers { export class Business { public static get(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/locations/businesses', ...options }); @@ -57,10 +57,10 @@ export class Business { export class Locations { public static get(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/locations', ...options }); } static business = Business; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts index 95401d19c..3c9d90569 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts @@ -82,4 +82,4 @@ export type GetResponse = GetResponses[keyof GetResponses]; export type ClientOptions = { baseUrl: 'https://api.example.com/v1' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts index f2b3eaf05..d898f11be 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts @@ -2144,4 +2144,4 @@ export const Generic_Schema_Duplicate_Issue_1_System_String_WritableSchema = { } }, additionalProperties: false -} as const; \ No newline at end of file +} as const; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts index ebc3a8457..4cf0ca9c4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base', throwOnError: true -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts index e54e0318f..6d229fd5d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (option * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options: }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = }; export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (op }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = (o }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Options }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opti }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (optio ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts index 20c92fc95..5c161731c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { postFooResponseTransformer } from './transformers.gen'; -import { vPostFooResponse } from './valibot.gen'; +import { vPostFooData, vPostFooResponse } from './valibot.gen'; import * as v from 'valibot'; -import { client as _heyApiClient } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,7 +22,10 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ + requestValidator: async (data) => { + return await v.parseAsync(vPostFooData, data); + }, responseTransformer: postFooResponseTransformer, responseValidator: async (data) => { return await v.parseAsync(vPostFooResponse, data); @@ -30,4 +33,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts index 419690a91..cc9dcf841 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts @@ -10,4 +10,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const postFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts index 8250a422d..ba800b837 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts @@ -33,4 +33,4 @@ export type UserId = TypeID<'user'>; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts index e49e2e14e..a030d9354 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts @@ -25,4 +25,4 @@ export const vPostFooData = v.object({ /** * OK */ -export const vPostFooResponse = vFoo; \ No newline at end of file +export const vPostFooResponse = vFoo; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts index 67d605869..9067c31ee 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts @@ -1,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; import { zPostFooData, zPostFooResponse } from './zod.gen'; import { postFooResponseTransformer } from './transformers.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -21,7 +21,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ requestValidator: async (data) => { return await zPostFooData.parseAsync(data); }, @@ -32,4 +32,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts index 419690a91..cc9dcf841 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts @@ -10,4 +10,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const postFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts index 8250a422d..ba800b837 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts @@ -33,4 +33,4 @@ export type UserId = TypeID<'user'>; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts index bfee2ff85..477553d5c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts index 0bcefeff0..21ae98a77 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts @@ -109,4 +109,4 @@ export type PostFooWriteResponse = PostFooWriteResponses[keyof PostFooWriteRespo export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts index c259bf2de..b73d450d0 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts @@ -92,4 +92,4 @@ export type PostFooWriteResponse = PostFooWriteResponses[keyof PostFooWriteRespo export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts index ce759964c..5e6302120 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -18,7 +18,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (tags) { params.tags = tags as unknown as undefined; } @@ -194,7 +194,7 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { +export const deleteFooMutation = (options: Options): UseMutationOptions, Error> => { return { mutation: async (fnOptions) => { const { data } = await deleteFoo({ @@ -692,4 +692,4 @@ export const putWithFormUrlEncodedMutation = (options: Options = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts deleted file mode 100644 index 27d358cc3..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, collectionFormat } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { CollectionFormatData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const collectionFormatQueryKey = (options: Options) => createQueryKey('collectionFormat', options); - -export const collectionFormatQuery = (options: Options): UseQueryOptions => { - return { - key: collectionFormatQueryKey(options), - query: async (context) => { - const { data } = await collectionFormat({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts deleted file mode 100644 index 2d73a2a25..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts +++ /dev/null @@ -1,69 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, complexTypes, complexParams } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const complexTypesQueryKey = (options: Options) => createQueryKey('complexTypes', options); - -export const complexTypesQuery = (options: Options): UseQueryOptions => { - return { - key: complexTypesQueryKey(options), - query: async (context) => { - const { data } = await complexTypes({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const complexParamsMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await complexParams({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts deleted file mode 100644 index 1b5096aea..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts +++ /dev/null @@ -1,82 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithDefaultParametersQueryKey = (options?: Options) => createQueryKey('callWithDefaultParameters', options); - -export const callWithDefaultParametersQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithDefaultParametersQueryKey(options), - query: async (context) => { - const { data } = await callWithDefaultParameters({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithDefaultOptionalParametersMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDefaultOptionalParameters({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callToTestOrderOfParamsMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callToTestOrderOfParams({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts deleted file mode 100644 index b35ad56ae..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, deprecatedCall } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { DeprecatedCallData } from '../../types.gen'; - -/** - * @deprecated - */ -export const deprecatedCallMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await deprecatedCall({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts deleted file mode 100644 index 05f30e6d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithDescriptions } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { CallWithDescriptionsData } from '../../types.gen'; - -export const callWithDescriptionsMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDescriptions({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts deleted file mode 100644 index ed05f186b..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts +++ /dev/null @@ -1,95 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, duplicateName, duplicateName2, duplicateName3, duplicateName4 } from '../../sdk.gen'; -import type { UseMutationOptions, _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export const duplicateNameMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const duplicateName2QueryKey = (options?: Options) => createQueryKey('duplicateName2', options); - -export const duplicateName2Query = (options?: Options): UseQueryOptions => { - return { - key: duplicateName2QueryKey(options), - query: async (context) => { - const { data } = await duplicateName2({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const duplicateName3Mutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName3({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const duplicateName4Mutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName4({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts deleted file mode 100644 index 90dc048d7..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, testErrorCode } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { TestErrorCodeData } from '../../types.gen'; - -export const testErrorCodeMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await testErrorCode({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts deleted file mode 100644 index 49a263c90..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, fileResponse } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { FileResponseData, FileResponseResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const fileResponseQueryKey = (options: Options) => createQueryKey('fileResponse', options); - -export const fileResponseQuery = (options: Options): UseQueryOptions => { - return { - key: fileResponseQueryKey(options), - query: async (context) => { - const { data } = await fileResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts deleted file mode 100644 index 64656dee0..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, postApiVbyApiVersionFormData } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; - -export const postApiVbyApiVersionFormDataMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postApiVbyApiVersionFormData({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts deleted file mode 100644 index 2100075e4..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithResultFromHeader } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { CallWithResultFromHeaderData } from '../../types.gen'; - -export const callWithResultFromHeaderMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithResultFromHeader({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts deleted file mode 100644 index 1bf294ca7..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts +++ /dev/null @@ -1,72 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, dummyA, dummyB } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DummyAData, DummyAResponse, DummyBData, DummyBResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const dummyAQueryKey = (options?: Options) => createQueryKey('dummyA', options); - -export const dummyAQuery = (options?: Options): UseQueryOptions => { - return { - key: dummyAQueryKey(options), - query: async (context) => { - const { data } = await dummyA({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const dummyBQueryKey = (options?: Options) => createQueryKey('dummyB', options); - -export const dummyBQuery = (options?: Options): UseQueryOptions => { - return { - key: dummyBQueryKey(options), - query: async (context) => { - const { data } = await dummyB({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts deleted file mode 100644 index f808551bc..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/NoContent.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithNoContentResponse } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { CallWithNoContentResponseData, CallWithNoContentResponseResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithNoContentResponseQueryKey = (options?: Options) => createQueryKey('callWithNoContentResponse', options); - -export const callWithNoContentResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithNoContentResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithNoContentResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" deleted file mode 100644 index a01de3df0..000000000 --- "a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" +++ /dev/null @@ -1,34 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../types.gen'; - -export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -/** - * Login User - */ -export const putWithFormUrlEncodedMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await putWithFormUrlEncoded({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts deleted file mode 100644 index 6c54734b5..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts +++ /dev/null @@ -1,108 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, deleteFoo, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam } from '../../sdk.gen'; -import type { UseMutationOptions, _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export const deleteFooMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await deleteFoo({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithParametersMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithParameters({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithWeirdParameterNamesMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithWeirdParameterNames({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const getCallWithOptionalParamQueryKey = (options: Options) => createQueryKey('getCallWithOptionalParam', options); - -export const getCallWithOptionalParamQuery = (options: Options): UseQueryOptions => { - return { - key: getCallWithOptionalParamQueryKey(options), - query: async (context) => { - const { data } = await getCallWithOptionalParam({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const postCallWithOptionalParamMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postCallWithOptionalParam({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts deleted file mode 100644 index 843f64910..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, postApiVbyApiVersionRequestBody } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; - -export const postApiVbyApiVersionRequestBodyMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postApiVbyApiVersionRequestBody({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts deleted file mode 100644 index fb4f50eab..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts +++ /dev/null @@ -1,98 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithResponseAndNoContentResponse, callWithResponse, callWithDuplicateResponses, callWithResponses } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => createQueryKey('callWithResponseAndNoContentResponse', options); - -export const callWithResponseAndNoContentResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithResponseAndNoContentResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithResponseAndNoContentResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithResponseQueryKey = (options?: Options) => createQueryKey('callWithResponse', options); - -export const callWithResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithDuplicateResponsesMutation = (options?: Options): UseMutationOptions, CallWithDuplicateResponsesError> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDuplicateResponses({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithResponsesMutation = (options?: Options): UseMutationOptions, CallWithResponsesError> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithResponses({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts deleted file mode 100644 index e4d9c13d7..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts +++ /dev/null @@ -1,124 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, apiVVersionODataControllerCount, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const apiVVersionODataControllerCountQueryKey = (options?: Options) => createQueryKey('apiVVersionODataControllerCount', options); - -export const apiVVersionODataControllerCountQuery = (options?: Options): UseQueryOptions => { - return { - key: apiVVersionODataControllerCountQueryKey(options), - query: async (context) => { - const { data } = await apiVVersionODataControllerCount({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const deleteCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await deleteCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => createQueryKey('getCallWithoutParametersAndResponse', options); - -export const getCallWithoutParametersAndResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: getCallWithoutParametersAndResponseQueryKey(options), - query: async (context) => { - const { data } = await getCallWithoutParametersAndResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const patchCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await patchCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const postCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const putCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await putCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts deleted file mode 100644 index 822ebd8fe..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, types } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { TypesData, TypesResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const typesQueryKey = (options: Options) => createQueryKey('types', options); - -export const typesQuery = (options: Options): UseQueryOptions => { - return { - key: typesQueryKey(options), - query: async (context) => { - const { data } = await types({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts deleted file mode 100644 index 444d8f9ec..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, uploadFile } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { UploadFileData, UploadFileResponse } from '../../types.gen'; - -export const uploadFileMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await uploadFile({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts deleted file mode 100644 index f11c6546a..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts +++ /dev/null @@ -1,111 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, getApiVbyApiVersionSimpleOperation } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const exportQueryKey = (options?: Options) => createQueryKey('export', options); - -export const exportQuery = (options?: Options): UseQueryOptions => { - return { - key: exportQueryKey(options), - query: async (context) => { - const { data } = await export_({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const patchApiVbyApiVersionNoTagMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await patchApiVbyApiVersionNoTag({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const importMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await import_({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const fooWowMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await fooWow({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options) => createQueryKey('getApiVbyApiVersionSimpleOperation', options); - -export const getApiVbyApiVersionSimpleOperationQuery = (options: Options): UseQueryOptions => { - return { - key: getApiVbyApiVersionSimpleOperationQueryKey(options), - query: async (context) => { - const { data } = await getApiVbyApiVersionSimpleOperation({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts deleted file mode 100644 index e47a721b5..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts +++ /dev/null @@ -1,69 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, multipartResponse, multipartRequest } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { MultipartResponseData, MultipartResponseResponse, MultipartRequestData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const multipartResponseQueryKey = (options?: Options) => createQueryKey('multipartResponse', options); - -export const multipartResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: multipartResponseQueryKey(options), - query: async (context) => { - const { data } = await multipartResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const multipartRequestMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await multipartRequest({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts deleted file mode 100644 index 14f2d878c..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig = (override?: Config) => Config & T>; - -export const client = createClient(createConfig({ - baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts deleted file mode 100644 index f68339318..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ /dev/null @@ -1,267 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { createSseClient } from '../core/serverSentEvents.gen'; -import type { HttpMethod } from '../core/types.gen'; -import type { - Client, - Config, - RequestOptions, - ResolvedRequestOptions, -} from './types.gen'; -import { - buildUrl, - createConfig, - createInterceptors, - getParseAs, - mergeConfigs, - mergeHeaders, - setAuthParams, -} from './utils.gen'; - -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - -export const createClient = (config: Config = {}): Client => { - let _config = mergeConfigs(createConfig(), config); - - const getConfig = (): Config => ({ ..._config }); - - const setConfig = (config: Config): Config => { - _config = mergeConfigs(_config, config); - return getConfig(); - }; - - const interceptors = createInterceptors< - Request, - Response, - unknown, - ResolvedRequestOptions - >(); - - const beforeRequest = async (options: RequestOptions) => { - const opts = { - ..._config, - ...options, - fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, - headers: mergeHeaders(_config.headers, options.headers), - serializedBody: undefined, - }; - - if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); - } - - if (opts.requestValidator) { - await opts.requestValidator(opts); - } - - if (opts.body && opts.bodySerializer) { - opts.serializedBody = opts.bodySerializer(opts.body); - } - - // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { - opts.headers.delete('Content-Type'); - } - - const url = buildUrl(opts); - - return { opts, url }; - }; - - const request: Client['request'] = async (options) => { - // @ts-expect-error - const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', - ...opts, - body: opts.serializedBody, - }; - - let request = new Request(url, requestInit); - - for (const fn of interceptors.request._fns) { - if (fn) { - request = await fn(request, opts); - } - } - - // fetch must be assigned here, otherwise it would throw the error: - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation - const _fetch = opts.fetch!; - let response = await _fetch(request); - - for (const fn of interceptors.response._fns) { - if (fn) { - response = await fn(response, request, opts); - } - } - - const result = { - request, - response, - }; - - if (response.ok) { - const parseAs = - (opts.parseAs === 'auto' - ? getParseAs(response.headers.get('Content-Type')) - : opts.parseAs) ?? 'json'; - - if ( - response.status === 204 || - response.headers.get('Content-Length') === '0' - ) { - let emptyData: any; - switch (parseAs) { - case 'arrayBuffer': - case 'blob': - case 'text': - emptyData = await response[parseAs](); - break; - case 'formData': - emptyData = new FormData(); - break; - case 'stream': - emptyData = response.body; - break; - case 'json': - default: - emptyData = {}; - break; - } - return opts.responseStyle === 'data' - ? emptyData - : { - data: emptyData, - ...result, - }; - } - - let data: any; - switch (parseAs) { - case 'arrayBuffer': - case 'blob': - case 'formData': - case 'json': - case 'text': - data = await response[parseAs](); - break; - case 'stream': - return opts.responseStyle === 'data' - ? response.body - : { - data: response.body, - ...result, - }; - } - - if (parseAs === 'json') { - if (opts.responseValidator) { - await opts.responseValidator(data); - } - - if (opts.responseTransformer) { - data = await opts.responseTransformer(data); - } - } - - return opts.responseStyle === 'data' - ? data - : { - data, - ...result, - }; - } - - const textError = await response.text(); - let jsonError: unknown; - - try { - jsonError = JSON.parse(textError); - } catch { - // noop - } - - const error = jsonError ?? textError; - let finalError = error; - - for (const fn of interceptors.error._fns) { - if (fn) { - finalError = (await fn(error, response, request, opts)) as string; - } - } - - finalError = finalError || ({} as string); - - if (opts.throwOnError) { - throw finalError; - } - - // TODO: we probably want to return error and improve types - return opts.responseStyle === 'data' - ? undefined - : { - error: finalError, - ...result, - }; - }; - - const makeMethodFn = - (method: Uppercase) => (options: RequestOptions) => - request({ ...options, method }); - - const makeSseFn = - (method: Uppercase) => async (options: RequestOptions) => { - const { opts, url } = await beforeRequest(options); - return createSseClient({ - ...opts, - body: opts.body as BodyInit | null | undefined, - headers: opts.headers as unknown as Record, - method, - onRequest: async (url, init) => { - let request = new Request(url, init); - for (const fn of interceptors.request._fns) { - if (fn) { - request = await fn(request, opts); - } - } - return request; - }, - url, - }); - }; - - return { - buildUrl, - connect: makeMethodFn('CONNECT'), - delete: makeMethodFn('DELETE'), - get: makeMethodFn('GET'), - getConfig, - head: makeMethodFn('HEAD'), - interceptors, - options: makeMethodFn('OPTIONS'), - patch: makeMethodFn('PATCH'), - post: makeMethodFn('POST'), - put: makeMethodFn('PUT'), - request, - setConfig, - sse: { - connect: makeSseFn('CONNECT'), - delete: makeSseFn('DELETE'), - get: makeSseFn('GET'), - head: makeSseFn('HEAD'), - options: makeSseFn('OPTIONS'), - patch: makeSseFn('PATCH'), - post: makeSseFn('POST'), - put: makeSseFn('PUT'), - trace: makeSseFn('TRACE'), - }, - trace: makeMethodFn('TRACE'), - } as Client; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts deleted file mode 100644 index 318a84b6a..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -export type { Auth } from '../core/auth.gen'; -export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; -export { - formDataBodySerializer, - jsonBodySerializer, - urlSearchParamsBodySerializer, -} from '../core/bodySerializer.gen'; -export { buildClientParams } from '../core/params.gen'; -export { createClient } from './client.gen'; -export type { - Client, - ClientOptions, - Config, - CreateClientConfig, - Options, - OptionsLegacyParser, - RequestOptions, - RequestResult, - ResolvedRequestOptions, - ResponseStyle, - TDataShape, -} from './types.gen'; -export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts deleted file mode 100644 index 1a005b51e..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts +++ /dev/null @@ -1,268 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Auth } from '../core/auth.gen'; -import type { - ServerSentEventsOptions, - ServerSentEventsResult, -} from '../core/serverSentEvents.gen'; -import type { - Client as CoreClient, - Config as CoreConfig, -} from '../core/types.gen'; -import type { Middleware } from './utils.gen'; - -export type ResponseStyle = 'data' | 'fields'; - -export interface Config - extends Omit, - CoreConfig { - /** - * Base URL for all requests made by this client. - */ - baseUrl?: T['baseUrl']; - /** - * Fetch API implementation. You can use this option to provide a custom - * fetch instance. - * - * @default globalThis.fetch - */ - fetch?: typeof fetch; - /** - * Please don't use the Fetch client for Next.js applications. The `next` - * options won't have any effect. - * - * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. - */ - next?: never; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ - parseAs?: - | 'arrayBuffer' - | 'auto' - | 'blob' - | 'formData' - | 'json' - | 'stream' - | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ - responseStyle?: ResponseStyle; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ - throwOnError?: T['throwOnError']; -} - -export interface RequestOptions< - TData = unknown, - TResponseStyle extends ResponseStyle = 'fields', - ThrowOnError extends boolean = boolean, - Url extends string = string, -> extends Config<{ - responseStyle: TResponseStyle; - throwOnError: ThrowOnError; - }>, - Pick< - ServerSentEventsOptions, - | 'onSseError' - | 'onSseEvent' - | 'sseDefaultRetryDelay' - | 'sseMaxRetryAttempts' - | 'sseMaxRetryDelay' - > { - /** - * Any body that you want to add to your request. - * - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} - */ - body?: unknown; - path?: Record; - query?: Record; - /** - * Security mechanism(s) to use for the request. - */ - security?: ReadonlyArray; - url: Url; -} - -export interface ResolvedRequestOptions< - TResponseStyle extends ResponseStyle = 'fields', - ThrowOnError extends boolean = boolean, - Url extends string = string, -> extends RequestOptions { - serializedBody?: string; -} - -export type RequestResult< - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = boolean, - TResponseStyle extends ResponseStyle = 'fields', -> = ThrowOnError extends true - ? Promise< - TResponseStyle extends 'data' - ? TData extends Record - ? TData[keyof TData] - : TData - : { - data: TData extends Record - ? TData[keyof TData] - : TData; - request: Request; - response: Response; - } - > - : Promise< - TResponseStyle extends 'data' - ? - | (TData extends Record - ? TData[keyof TData] - : TData) - | undefined - : ( - | { - data: TData extends Record - ? TData[keyof TData] - : TData; - error: undefined; - } - | { - data: undefined; - error: TError extends Record - ? TError[keyof TError] - : TError; - } - ) & { - request: Request; - response: Response; - } - >; - -export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; -} - -type MethodFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'>, -) => RequestResult; - -type SseFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'>, -) => Promise>; - -type RequestFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'> & - Pick< - Required>, - 'method' - >, -) => RequestResult; - -type BuildUrlFn = < - TData extends { - body?: unknown; - path?: Record; - query?: Record; - url: string; - }, ->( - options: Pick & Options, -) => string; - -export type Client = CoreClient< - RequestFn, - Config, - MethodFn, - BuildUrlFn, - SseFn -> & { - interceptors: Middleware; -}; - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig = ( - override?: Config, -) => Config & T>; - -export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; - url: string; -} - -type OmitKeys = Pick>; - -export type Options< - TData extends TDataShape = TDataShape, - ThrowOnError extends boolean = boolean, - TResponse = unknown, - TResponseStyle extends ResponseStyle = 'fields', -> = OmitKeys< - RequestOptions, - 'body' | 'path' | 'query' | 'url' -> & - Omit; - -export type OptionsLegacyParser< - TData = unknown, - ThrowOnError extends boolean = boolean, - TResponseStyle extends ResponseStyle = 'fields', -> = TData extends { body?: any } - ? TData extends { headers?: any } - ? OmitKeys< - RequestOptions, - 'body' | 'headers' | 'url' - > & - TData - : OmitKeys< - RequestOptions, - 'body' | 'url' - > & - TData & - Pick, 'headers'> - : TData extends { headers?: any } - ? OmitKeys< - RequestOptions, - 'headers' | 'url' - > & - TData & - Pick, 'body'> - : OmitKeys, 'url'> & - TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts deleted file mode 100644 index a47509522..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts +++ /dev/null @@ -1,327 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { getAuthToken } from '../core/auth.gen'; -import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; -import { jsonBodySerializer } from '../core/bodySerializer.gen'; -import { - serializeArrayParam, - serializeObjectParam, - serializePrimitiveParam, -} from '../core/pathSerializer.gen'; -import { getUrl } from '../core/utils.gen'; -import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; - -export const createQuerySerializer = ({ - allowReserved, - array, - object, -}: QuerySerializerOptions = {}) => { - const querySerializer = (queryParams: T) => { - const search: string[] = []; - if (queryParams && typeof queryParams === 'object') { - for (const name in queryParams) { - const value = queryParams[name]; - - if (value === undefined || value === null) { - continue; - } - - if (Array.isArray(value)) { - const serializedArray = serializeArrayParam({ - allowReserved, - explode: true, - name, - style: 'form', - value, - ...array, - }); - if (serializedArray) search.push(serializedArray); - } else if (typeof value === 'object') { - const serializedObject = serializeObjectParam({ - allowReserved, - explode: true, - name, - style: 'deepObject', - value: value as Record, - ...object, - }); - if (serializedObject) search.push(serializedObject); - } else { - const serializedPrimitive = serializePrimitiveParam({ - allowReserved, - name, - value: value as string, - }); - if (serializedPrimitive) search.push(serializedPrimitive); - } - } - } - return search.join('&'); - }; - return querySerializer; -}; - -/** - * Infers parseAs value from provided Content-Type header. - */ -export const getParseAs = ( - contentType: string | null, -): Exclude => { - if (!contentType) { - // If no Content-Type header is provided, the best we can do is return the raw response body, - // which is effectively the same as the 'stream' option. - return 'stream'; - } - - const cleanContent = contentType.split(';')[0]?.trim(); - - if (!cleanContent) { - return; - } - - if ( - cleanContent.startsWith('application/json') || - cleanContent.endsWith('+json') - ) { - return 'json'; - } - - if (cleanContent === 'multipart/form-data') { - return 'formData'; - } - - if ( - ['application/', 'audio/', 'image/', 'video/'].some((type) => - cleanContent.startsWith(type), - ) - ) { - return 'blob'; - } - - if (cleanContent.startsWith('text/')) { - return 'text'; - } - - return; -}; - -const checkForExistence = ( - options: Pick & { - headers: Headers; - }, - name?: string, -): boolean => { - if (!name) { - return false; - } - if ( - options.headers.has(name) || - options.query?.[name] || - options.headers.get('Cookie')?.includes(`${name}=`) - ) { - return true; - } - return false; -}; - -export const setAuthParams = async ({ - security, - ...options -}: Pick, 'security'> & - Pick & { - headers: Headers; - }) => { - for (const auth of security) { - if (checkForExistence(options, auth.name)) { - continue; - } - - const token = await getAuthToken(auth, options.auth); - - if (!token) { - continue; - } - - const name = auth.name ?? 'Authorization'; - - switch (auth.in) { - case 'query': - if (!options.query) { - options.query = {}; - } - options.query[name] = token; - break; - case 'cookie': - options.headers.append('Cookie', `${name}=${token}`); - break; - case 'header': - default: - options.headers.set(name, token); - break; - } - } -}; - -export const buildUrl: Client['buildUrl'] = (options) => - getUrl({ - baseUrl: options.baseUrl as string, - path: options.path, - query: options.query, - querySerializer: - typeof options.querySerializer === 'function' - ? options.querySerializer - : createQuerySerializer(options.querySerializer), - url: options.url, - }); - -export const mergeConfigs = (a: Config, b: Config): Config => { - const config = { ...a, ...b }; - if (config.baseUrl?.endsWith('/')) { - config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); - } - config.headers = mergeHeaders(a.headers, b.headers); - return config; -}; - -export const mergeHeaders = ( - ...headers: Array['headers'] | undefined> -): Headers => { - const mergedHeaders = new Headers(); - for (const header of headers) { - if (!header || typeof header !== 'object') { - continue; - } - - const iterator = - header instanceof Headers ? header.entries() : Object.entries(header); - - for (const [key, value] of iterator) { - if (value === null) { - mergedHeaders.delete(key); - } else if (Array.isArray(value)) { - for (const v of value) { - mergedHeaders.append(key, v as string); - } - } else if (value !== undefined) { - // assume object headers are meant to be JSON stringified, i.e. their - // content value in OpenAPI specification is 'application/json' - mergedHeaders.set( - key, - typeof value === 'object' ? JSON.stringify(value) : (value as string), - ); - } - } - } - return mergedHeaders; -}; - -type ErrInterceptor = ( - error: Err, - response: Res, - request: Req, - options: Options, -) => Err | Promise; - -type ReqInterceptor = ( - request: Req, - options: Options, -) => Req | Promise; - -type ResInterceptor = ( - response: Res, - request: Req, - options: Options, -) => Res | Promise; - -class Interceptors { - _fns: (Interceptor | null)[]; - - constructor() { - this._fns = []; - } - - clear() { - this._fns = []; - } - - getInterceptorIndex(id: number | Interceptor): number { - if (typeof id === 'number') { - return this._fns[id] ? id : -1; - } else { - return this._fns.indexOf(id); - } - } - exists(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - return !!this._fns[index]; - } - - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; - } - } - - update(id: number | Interceptor, fn: Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; - return id; - } else { - return false; - } - } - - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; - } -} - -// `createInterceptors()` response, meant for external use as it does not -// expose internals -export interface Middleware { - error: Pick< - Interceptors>, - 'eject' | 'use' - >; - request: Pick>, 'eject' | 'use'>; - response: Pick< - Interceptors>, - 'eject' | 'use' - >; -} - -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ - error: new Interceptors>(), - request: new Interceptors>(), - response: new Interceptors>(), -}); - -const defaultQuerySerializer = createQuerySerializer({ - allowReserved: false, - array: { - explode: true, - style: 'form', - }, - object: { - explode: true, - style: 'deepObject', - }, -}); - -const defaultHeaders = { - 'Content-Type': 'application/json', -}; - -export const createConfig = ( - override: Config & T> = {}, -): Config & T> => ({ - ...jsonBodySerializer, - headers: defaultHeaders, - parseAs: 'auto', - querySerializer: defaultQuerySerializer, - ...override, -}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts deleted file mode 100644 index f8a73266f..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -export type AuthToken = string | undefined; - -export interface Auth { - /** - * Which part of the request do we use to send the auth? - * - * @default 'header' - */ - in?: 'header' | 'query' | 'cookie'; - /** - * Header or query parameter name. - * - * @default 'Authorization' - */ - name?: string; - scheme?: 'basic' | 'bearer'; - type: 'apiKey' | 'http'; -} - -export const getAuthToken = async ( - auth: Auth, - callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, -): Promise => { - const token = - typeof callback === 'function' ? await callback(auth) : callback; - - if (!token) { - return; - } - - if (auth.scheme === 'bearer') { - return `Bearer ${token}`; - } - - if (auth.scheme === 'basic') { - return `Basic ${btoa(token)}`; - } - - return token; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts deleted file mode 100644 index 49cd8925e..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { - ArrayStyle, - ObjectStyle, - SerializerOptions, -} from './pathSerializer.gen'; - -export type QuerySerializer = (query: Record) => string; - -export type BodySerializer = (body: any) => any; - -export interface QuerySerializerOptions { - allowReserved?: boolean; - array?: SerializerOptions; - object?: SerializerOptions; -} - -const serializeFormDataPair = ( - data: FormData, - key: string, - value: unknown, -): void => { - if (typeof value === 'string' || value instanceof Blob) { - data.append(key, value); - } else if (value instanceof Date) { - data.append(key, value.toISOString()); - } else { - data.append(key, JSON.stringify(value)); - } -}; - -const serializeUrlSearchParamsPair = ( - data: URLSearchParams, - key: string, - value: unknown, -): void => { - if (typeof value === 'string') { - data.append(key, value); - } else { - data.append(key, JSON.stringify(value)); - } -}; - -export const formDataBodySerializer = { - bodySerializer: | Array>>( - body: T, - ): FormData => { - const data = new FormData(); - - Object.entries(body).forEach(([key, value]) => { - if (value === undefined || value === null) { - return; - } - if (Array.isArray(value)) { - value.forEach((v) => serializeFormDataPair(data, key, v)); - } else { - serializeFormDataPair(data, key, value); - } - }); - - return data; - }, -}; - -export const jsonBodySerializer = { - bodySerializer: (body: T): string => - JSON.stringify(body, (_key, value) => - typeof value === 'bigint' ? value.toString() : value, - ), -}; - -export const urlSearchParamsBodySerializer = { - bodySerializer: | Array>>( - body: T, - ): string => { - const data = new URLSearchParams(); - - Object.entries(body).forEach(([key, value]) => { - if (value === undefined || value === null) { - return; - } - if (Array.isArray(value)) { - value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); - } else { - serializeUrlSearchParamsPair(data, key, value); - } - }); - - return data.toString(); - }, -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts deleted file mode 100644 index 71c88e852..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts +++ /dev/null @@ -1,153 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -type Slot = 'body' | 'headers' | 'path' | 'query'; - -export type Field = - | { - in: Exclude; - /** - * Field name. This is the name we want the user to see and use. - */ - key: string; - /** - * 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; - } - | { - in: Extract; - /** - * Key isn't required for bodies. - */ - key?: string; - map?: string; - }; - -export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; -} - -export type FieldsConfig = ReadonlyArray; - -const extraPrefixesMap: Record = { - $body_: 'body', - $headers_: 'headers', - $path_: 'path', - $query_: 'query', -}; -const extraPrefixes = Object.entries(extraPrefixesMap); - -type KeyMap = Map< - string, - { - in: Slot; - map?: string; - } ->; - -const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { - if (!map) { - map = new Map(); - } - - for (const config of fields) { - if ('in' in config) { - if (config.key) { - map.set(config.key, { - in: config.in, - map: config.map, - }); - } - } else if (config.args) { - buildKeyMap(config.args, map); - } - } - - return map; -}; - -interface Params { - body: unknown; - headers: Record; - path: Record; - query: Record; -} - -const stripEmptySlots = (params: Params) => { - for (const [slot, value] of Object.entries(params)) { - if (value && typeof value === 'object' && !Object.keys(value).length) { - delete params[slot as Slot]; - } - } -}; - -export const buildClientParams = ( - args: ReadonlyArray, - fields: FieldsConfig, -) => { - const params: Params = { - body: {}, - headers: {}, - path: {}, - query: {}, - }; - - const map = buildKeyMap(fields); - - let config: FieldsConfig[number] | undefined; - - for (const [index, arg] of args.entries()) { - if (fields[index]) { - config = fields[index]; - } - - if (!config) { - continue; - } - - if ('in' in config) { - if (config.key) { - const field = map.get(config.key)!; - const name = field.map || config.key; - (params[field.in] as Record)[name] = arg; - } else { - params.body = arg; - } - } else { - for (const [key, value] of Object.entries(arg ?? {})) { - const field = map.get(key); - - if (field) { - const name = field.map || key; - (params[field.in] as Record)[name] = value; - } else { - const extra = extraPrefixes.find(([prefix]) => - key.startsWith(prefix), - ); - - if (extra) { - const [prefix, slot] = extra; - (params[slot] as Record)[ - key.slice(prefix.length) - ] = value; - } else { - for (const [slot, allowed] of Object.entries( - config.allowExtra ?? {}, - )) { - if (allowed) { - (params[slot as Slot] as Record)[key] = value; - break; - } - } - } - } - } - } - } - - stripEmptySlots(params); - - return params; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts deleted file mode 100644 index 8d9993104..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts +++ /dev/null @@ -1,181 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -interface SerializeOptions - extends SerializePrimitiveOptions, - SerializerOptions {} - -interface SerializePrimitiveOptions { - allowReserved?: boolean; - name: string; -} - -export interface SerializerOptions { - /** - * @default true - */ - explode: boolean; - style: T; -} - -export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; -export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; -type MatrixStyle = 'label' | 'matrix' | 'simple'; -export type ObjectStyle = 'form' | 'deepObject'; -type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; - -interface SerializePrimitiveParam extends SerializePrimitiveOptions { - value: string; -} - -export const separatorArrayExplode = (style: ArraySeparatorStyle) => { - switch (style) { - case 'label': - return '.'; - case 'matrix': - return ';'; - case 'simple': - return ','; - default: - return '&'; - } -}; - -export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { - switch (style) { - case 'form': - return ','; - case 'pipeDelimited': - return '|'; - case 'spaceDelimited': - return '%20'; - default: - return ','; - } -}; - -export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { - switch (style) { - case 'label': - return '.'; - case 'matrix': - return ';'; - case 'simple': - return ','; - default: - return '&'; - } -}; - -export const serializeArrayParam = ({ - allowReserved, - explode, - name, - style, - value, -}: SerializeOptions & { - value: unknown[]; -}) => { - if (!explode) { - const joinedValues = ( - allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) - ).join(separatorArrayNoExplode(style)); - switch (style) { - case 'label': - return `.${joinedValues}`; - case 'matrix': - return `;${name}=${joinedValues}`; - case 'simple': - return joinedValues; - default: - return `${name}=${joinedValues}`; - } - } - - const separator = separatorArrayExplode(style); - const joinedValues = value - .map((v) => { - if (style === 'label' || style === 'simple') { - return allowReserved ? v : encodeURIComponent(v as string); - } - - return serializePrimitiveParam({ - allowReserved, - name, - value: v as string, - }); - }) - .join(separator); - return style === 'label' || style === 'matrix' - ? separator + joinedValues - : joinedValues; -}; - -export const serializePrimitiveParam = ({ - allowReserved, - name, - value, -}: SerializePrimitiveParam) => { - if (value === undefined || value === null) { - return ''; - } - - if (typeof value === 'object') { - throw new Error( - 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', - ); - } - - return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; -}; - -export const serializeObjectParam = ({ - allowReserved, - explode, - name, - style, - value, - valueOnly, -}: SerializeOptions & { - value: Record | Date; - valueOnly?: boolean; -}) => { - if (value instanceof Date) { - return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; - } - - if (style !== 'deepObject' && !explode) { - let values: string[] = []; - Object.entries(value).forEach(([key, v]) => { - values = [ - ...values, - key, - allowReserved ? (v as string) : encodeURIComponent(v as string), - ]; - }); - const joinedValues = values.join(','); - switch (style) { - case 'form': - return `${name}=${joinedValues}`; - case 'label': - return `.${joinedValues}`; - case 'matrix': - return `;${name}=${joinedValues}`; - default: - return joinedValues; - } - } - - const separator = separatorObjectExplode(style); - const joinedValues = Object.entries(value) - .map(([key, v]) => - serializePrimitiveParam({ - allowReserved, - name: style === 'deepObject' ? `${name}[${key}]` : key, - value: v as string, - }), - ) - .join(separator); - return style === 'label' || style === 'matrix' - ? separator + joinedValues - : joinedValues; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts deleted file mode 100644 index f8fd78e28..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts +++ /dev/null @@ -1,264 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Config } from './types.gen'; - -export type ServerSentEventsOptions = Omit< - RequestInit, - 'method' -> & - Pick & { - /** - * Fetch API implementation. You can use this option to provide a custom - * fetch instance. - * - * @default globalThis.fetch - */ - fetch?: typeof fetch; - /** - * Implementing clients can call request interceptors inside this hook. - */ - onRequest?: (url: string, init: RequestInit) => Promise; - /** - * Callback invoked when a network or parsing error occurs during streaming. - * - * This option applies only if the endpoint returns a stream of events. - * - * @param error The error that occurred. - */ - onSseError?: (error: unknown) => void; - /** - * Callback invoked when an event is streamed from the server. - * - * This option applies only if the endpoint returns a stream of events. - * - * @param event Event streamed from the server. - * @returns Nothing (void). - */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; - /** - * Default retry delay in milliseconds. - * - * This option applies only if the endpoint returns a stream of events. - * - * @default 3000 - */ - sseDefaultRetryDelay?: number; - /** - * Maximum number of retry attempts before giving up. - */ - sseMaxRetryAttempts?: number; - /** - * Maximum retry delay in milliseconds. - * - * Applies only when exponential backoff is used. - * - * This option applies only if the endpoint returns a stream of events. - * - * @default 30000 - */ - sseMaxRetryDelay?: number; - /** - * Optional sleep function for retry backoff. - * - * Defaults to using `setTimeout`. - */ - sseSleepFn?: (ms: number) => Promise; - url: string; - }; - -export interface StreamEvent { - data: TData; - event?: string; - id?: string; - retry?: number; -} - -export type ServerSentEventsResult< - TData = unknown, - TReturn = void, - TNext = unknown, -> = { - stream: AsyncGenerator< - TData extends Record ? TData[keyof TData] : TData, - TReturn, - TNext - >; -}; - -export const createSseClient = ({ - onRequest, - onSseError, - onSseEvent, - responseTransformer, - responseValidator, - sseDefaultRetryDelay, - sseMaxRetryAttempts, - sseMaxRetryDelay, - sseSleepFn, - url, - ...options -}: ServerSentEventsOptions): ServerSentEventsResult => { - let lastEventId: string | undefined; - - const sleep = - sseSleepFn ?? - ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); - - const createStream = async function* () { - let retryDelay: number = sseDefaultRetryDelay ?? 3000; - let attempt = 0; - const signal = options.signal ?? new AbortController().signal; - - while (true) { - if (signal.aborted) break; - - attempt++; - - const headers = - options.headers instanceof Headers - ? options.headers - : new Headers(options.headers as Record | undefined); - - if (lastEventId !== undefined) { - headers.set('Last-Event-ID', lastEventId); - } - - try { - const requestInit: RequestInit = { - redirect: 'follow', - ...options, - body: options.serializedBody, - headers, - signal, - }; - let request = new Request(url, requestInit); - if (onRequest) { - request = await onRequest(url, requestInit); - } - // fetch must be assigned here, otherwise it would throw the error: - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation - const _fetch = options.fetch ?? globalThis.fetch; - const response = await _fetch(request); - - if (!response.ok) - throw new Error( - `SSE failed: ${response.status} ${response.statusText}`, - ); - - if (!response.body) throw new Error('No body in SSE response'); - - const reader = response.body - .pipeThrough(new TextDecoderStream()) - .getReader(); - - let buffer = ''; - - const abortHandler = () => { - try { - reader.cancel(); - } catch { - // noop - } - }; - - signal.addEventListener('abort', abortHandler); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) break; - buffer += value; - - const chunks = buffer.split('\n\n'); - buffer = chunks.pop() ?? ''; - - for (const chunk of chunks) { - const lines = chunk.split('\n'); - const dataLines: Array = []; - let eventName: string | undefined; - - for (const line of lines) { - if (line.startsWith('data:')) { - dataLines.push(line.replace(/^data:\s*/, '')); - } else if (line.startsWith('event:')) { - eventName = line.replace(/^event:\s*/, ''); - } else if (line.startsWith('id:')) { - lastEventId = line.replace(/^id:\s*/, ''); - } else if (line.startsWith('retry:')) { - const parsed = Number.parseInt( - line.replace(/^retry:\s*/, ''), - 10, - ); - if (!Number.isNaN(parsed)) { - retryDelay = parsed; - } - } - } - - let data: unknown; - let parsedJson = false; - - if (dataLines.length) { - const rawData = dataLines.join('\n'); - try { - data = JSON.parse(rawData); - parsedJson = true; - } catch { - data = rawData; - } - } - - if (parsedJson) { - if (responseValidator) { - await responseValidator(data); - } - - if (responseTransformer) { - data = await responseTransformer(data); - } - } - - onSseEvent?.({ - data, - event: eventName, - id: lastEventId, - retry: retryDelay, - }); - - if (dataLines.length) { - yield data as any; - } - } - } - } finally { - signal.removeEventListener('abort', abortHandler); - reader.releaseLock(); - } - - break; // exit loop on normal completion - } catch (error) { - // connection failed or aborted; retry after delay - onSseError?.(error); - - if ( - sseMaxRetryAttempts !== undefined && - attempt >= sseMaxRetryAttempts - ) { - break; // stop after firing error - } - - // exponential backoff: double retry each attempt, cap at 30s - const backoff = Math.min( - retryDelay * 2 ** (attempt - 1), - sseMaxRetryDelay ?? 30000, - ); - await sleep(backoff); - } - } - }; - - const stream = createStream(); - - return { stream }; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts deleted file mode 100644 index 643c070c9..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts +++ /dev/null @@ -1,118 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Auth, AuthToken } from './auth.gen'; -import type { - BodySerializer, - QuerySerializer, - QuerySerializerOptions, -} from './bodySerializer.gen'; - -export type HttpMethod = - | 'connect' - | 'delete' - | 'get' - | 'head' - | 'options' - | 'patch' - | 'post' - | 'put' - | 'trace'; - -export type Client< - RequestFn = never, - Config = unknown, - MethodFn = never, - BuildUrlFn = never, - SseFn = never, -> = { - /** - * Returns the final request URL. - */ - buildUrl: BuildUrlFn; - getConfig: () => Config; - request: RequestFn; - setConfig: (config: Config) => Config; -} & { - [K in HttpMethod]: MethodFn; -} & ([SseFn] extends [never] - ? { sse?: never } - : { sse: { [K in HttpMethod]: SseFn } }); - -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; - /** - * A function for serializing request body parameter. By default, - * {@link JSON.stringify()} will be used. - */ - bodySerializer?: BodySerializer | null; - /** - * An object containing any HTTP headers that you want to pre-populate your - * `Headers` object with. - * - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} - */ - headers?: - | RequestInit['headers'] - | Record< - string, - | string - | number - | boolean - | (string | number | boolean)[] - | null - | undefined - | unknown - >; - /** - * The request method. - * - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} - */ - method?: Uppercase; - /** - * A function for serializing request query parameters. By default, arrays - * will be exploded in form style, objects will be exploded in deepObject - * style, and reserved characters are percent-encoded. - * - * This method will have no effect if the native `paramsSerializer()` Axios - * API function is used. - * - * {@link https://swagger.io/docs/specification/serialization/#query View examples} - */ - querySerializer?: QuerySerializer | QuerySerializerOptions; - /** - * 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; - /** - * 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; - /** - * 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; -} - -type IsExactlyNeverOrNeverUndefined = [T] extends [never] - ? true - : [T] extends [never | undefined] - ? [undefined] extends [T] - ? false - : true - : false; - -export type OmitNever> = { - [K in keyof T as IsExactlyNeverOrNeverUndefined extends true - ? never - : K]: T[K]; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts deleted file mode 100644 index ac31396fe..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts +++ /dev/null @@ -1,114 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { QuerySerializer } from './bodySerializer.gen'; -import { - type ArraySeparatorStyle, - serializeArrayParam, - serializeObjectParam, - serializePrimitiveParam, -} from './pathSerializer.gen'; - -export interface PathSerializer { - path: Record; - url: string; -} - -export const PATH_PARAM_RE = /\{[^{}]+\}/g; - -export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { - let url = _url; - const matches = _url.match(PATH_PARAM_RE); - if (matches) { - for (const match of matches) { - let explode = false; - let name = match.substring(1, match.length - 1); - let style: ArraySeparatorStyle = 'simple'; - - if (name.endsWith('*')) { - explode = true; - name = name.substring(0, name.length - 1); - } - - if (name.startsWith('.')) { - name = name.substring(1); - style = 'label'; - } else if (name.startsWith(';')) { - name = name.substring(1); - style = 'matrix'; - } - - const value = path[name]; - - if (value === undefined || value === null) { - continue; - } - - if (Array.isArray(value)) { - url = url.replace( - match, - serializeArrayParam({ explode, name, style, value }), - ); - continue; - } - - if (typeof value === 'object') { - url = url.replace( - match, - serializeObjectParam({ - explode, - name, - style, - value: value as Record, - valueOnly: true, - }), - ); - continue; - } - - if (style === 'matrix') { - url = url.replace( - match, - `;${serializePrimitiveParam({ - name, - value: value as string, - })}`, - ); - continue; - } - - const replaceValue = encodeURIComponent( - style === 'label' ? `.${value as string}` : (value as string), - ); - url = url.replace(match, replaceValue); - } - } - return url; -}; - -export const getUrl = ({ - baseUrl, - path, - query, - querySerializer, - url: _url, -}: { - baseUrl?: string; - path?: Record; - query?: Record; - querySerializer: QuerySerializer; - url: string; -}) => { - const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; - let url = (baseUrl ?? '') + pathUrl; - if (path) { - url = defaultPathSerializer({ path, url }); - } - let search = query ? querySerializer(query) : ''; - if (search.startsWith('?')) { - search = search.substring(1); - } - if (search) { - url += `?${search}`; - } - return url; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/index.ts deleted file mode 100644 index e64537d21..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts deleted file mode 100644 index e79f50b13..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts +++ /dev/null @@ -1,409 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; - -export type Options = ClientOptions & { - /** - * You can provide a client instance returned by `createClient()` instead of - * individual options. This might be also useful if you want to implement a - * custom client. - */ - client?: Client; - /** - * You can pass arbitrary values through the `meta` object. This can be - * used to access values that aren't defined as part of the SDK function. - */ - meta?: Record; -}; - -export const export_ = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/no+tag', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/simple/$count', - ...options - }); -}; - -export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/simple:operation', - ...options - }); -}; - -export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', - ...options - }); -}; - -export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/descriptions', - ...options - }); -}; - -/** - * @deprecated - */ -export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/deprecated', - ...options - }); -}; - -export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/{parameterPath}', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/parameters', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/requestBody', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options?.headers - } - }); -}; - -export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - ...formDataBodySerializer, - url: '/api/v{api-version}/formData', - ...options, - headers: { - 'Content-Type': null, - ...options?.headers - } - }); -}; - -export const callWithDefaultParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/no-content', - ...options - }); -}; - -export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/response-and-no-content', - ...options - }); -}; - -export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/a', - ...options - }); -}; - -export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/b', - ...options - }); -}; - -export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/collectionFormat', - ...options - }); -}; - -export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/types', - ...options - }); -}; - -export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - ...urlSearchParamsBodySerializer, - url: '/api/v{api-version}/upload', - ...options, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - ...options.headers - } - }); -}; - -export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/file/{id}', - ...options - }); -}; - -export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/complex', - ...options - }); -}; - -export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multipart', - ...options - }); -}; - -export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - ...formDataBodySerializer, - url: '/api/v{api-version}/multipart', - ...options, - headers: { - 'Content-Type': null, - ...options?.headers - } - }); -}; - -export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/complex/{id}', - ...options, - headers: { - 'Content-Type': 'application/json-patch+json', - ...options.headers - } - }); -}; - -export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/header', - ...options - }); -}; - -export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/error', - ...options - }); -}; - -export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', - ...options - }); -}; - -/** - * Login User - */ -export const putWithFormUrlEncoded = (options: Options) => { - return (options.client ?? _heyApiClient).put({ - ...urlSearchParamsBodySerializer, - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', - ...options, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - ...options.headers - } - }); -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts deleted file mode 100644 index 39d454abb..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/types.gen.ts +++ /dev/null @@ -1,2047 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * Model with number-only name - */ -export type _400 = string; - -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; - -export type ExternalRefB = ExternalRefA; - -/** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ -export type CamelCaseCommentWithBreaks = number; - -/** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ -export type CommentWithBreaks = number; - -/** - * Testing backticks in string: `backticks` and ```multiple backticks``` should work - */ -export type CommentWithBackticks = number; - -/** - * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work - */ -export type CommentWithBackticksAndQuotes = number; - -/** - * Testing slashes in string: \backwards\\\ and /forwards/// should work - */ -export type CommentWithSlashes = number; - -/** - * Testing expression placeholders in string: ${expression} should work - */ -export type CommentWithExpressionPlaceholders = number; - -/** - * Testing quotes in string: 'single quote''' and "double quotes""" should work - */ -export type CommentWithQuotes = number; - -/** - * Testing reserved characters in string: * inline * and ** inline ** should work - */ -export type CommentWithReservedCharacters = number; - -/** - * This is a simple number - */ -export type SimpleInteger = number; - -/** - * This is a simple boolean - */ -export type SimpleBoolean = boolean; - -/** - * This is a simple string - */ -export type SimpleString = string; - -/** - * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) - */ -export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; - -/** - * This is a simple file - */ -export type SimpleFile = Blob | File; - -/** - * This is a simple reference - */ -export type SimpleReference = ModelWithString; - -/** - * This is a simple string - */ -export type SimpleStringWithPattern = string | null; - -/** - * This is a simple enum with strings - */ -export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; - -export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; - -/** - * This is a simple enum with numbers - */ -export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; - -/** - * Success=1,Warning=2,Error=3 - */ -export type EnumFromDescription = number; - -/** - * This is a simple enum with numbers - */ -export type EnumWithExtensions = 200 | 400 | 500; - -export type EnumWithXEnumNames = 0 | 1 | 2; - -/** - * This is a simple array with numbers - */ -export type ArrayWithNumbers = Array; - -/** - * This is a simple array with booleans - */ -export type ArrayWithBooleans = Array; - -/** - * This is a simple array with strings - */ -export type ArrayWithStrings = Array; - -/** - * This is a simple array with references - */ -export type ArrayWithReferences = Array; - -/** - * This is a simple array containing an array - */ -export type ArrayWithArray = Array>; - -/** - * This is a simple array with properties - */ -export type ArrayWithProperties = Array<{ - '16x16'?: CamelCaseCommentWithBreaks; - bar?: string; -}>; - -/** - * This is a simple array with any of properties - */ -export type ArrayWithAnyOfProperties = Array<{ - foo?: string; -} | { - bar?: string; -}>; - -export type AnyOfAnyAndNull = { - data?: unknown; -}; - -/** - * This is a simple array with any of properties - */ -export type AnyOfArrays = { - results?: Array<{ - foo?: string; - } | { - bar?: string; - }>; -}; - -/** - * This is a string dictionary - */ -export type DictionaryWithString = { - [key: string]: string; -}; - -export type DictionaryWithPropertiesAndAdditionalProperties = { - foo?: number; - bar?: boolean; - [key: string]: string | number | boolean | undefined; -}; - -/** - * This is a string reference - */ -export type DictionaryWithReference = { - [key: string]: ModelWithString; -}; - -/** - * This is a complex dictionary - */ -export type DictionaryWithArray = { - [key: string]: Array; -}; - -/** - * This is a string dictionary - */ -export type DictionaryWithDictionary = { - [key: string]: { - [key: string]: string; - }; -}; - -/** - * This is a complex dictionary - */ -export type DictionaryWithProperties = { - [key: string]: { - foo?: string; - bar?: string; - }; -}; - -/** - * This is a model with one number property - */ -export type ModelWithInteger = { - /** - * This is a simple number property - */ - prop?: number; -}; - -/** - * This is a model with one boolean property - */ -export type ModelWithBoolean = { - /** - * This is a simple boolean property - */ - prop?: boolean; -}; - -/** - * This is a model with one string property - */ -export type ModelWithString = { - /** - * This is a simple string property - */ - prop?: string; -}; - -/** - * This is a model with one string property - */ -export type ModelWithStringError = { - /** - * This is a simple string property - */ - prop?: string; -}; - -/** - * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) - */ -export type ModelFromZendesk = string; - -/** - * This is a model with one string property - */ -export type ModelWithNullableString = { - /** - * This is a simple string property - */ - nullableProp1?: string | null; - /** - * This is a simple string property - */ - nullableRequiredProp1: string | null; - /** - * This is a simple string property - */ - nullableProp2?: string | null; - /** - * This is a simple string property - */ - nullableRequiredProp2: string | null; - /** - * This is a simple enum with strings - */ - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; -}; - -/** - * This is a model with one enum - */ -export type ModelWithEnum = { - /** - * This is a simple enum with strings - */ - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; - /** - * These are the HTTP error code enums - */ - statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; - /** - * Simple boolean enum - */ - bool?: true; -}; - -/** - * This is a model with one enum with escaped name - */ -export type ModelWithEnumWithHyphen = { - /** - * Foo-Bar-Baz-Qux - */ - 'foo-bar-baz-qux'?: '3.0'; -}; - -/** - * This is a model with one enum - */ -export type ModelWithEnumFromDescription = { - /** - * Success=1,Warning=2,Error=3 - */ - test?: number; -}; - -/** - * This is a model with nested enums - */ -export type ModelWithNestedEnums = { - dictionaryWithEnum?: { - [key: string]: 'Success' | 'Warning' | 'Error'; - }; - dictionaryWithEnumFromDescription?: { - [key: string]: number; - }; - arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; - arrayWithDescription?: Array; - /** - * This is a simple enum with strings - */ - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; -}; - -/** - * This is a model with one property containing a reference - */ -export type ModelWithReference = { - prop?: ModelWithProperties; -}; - -/** - * This is a model with one property containing an array - */ -export type ModelWithArrayReadOnlyAndWriteOnly = { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -}; - -/** - * This is a model with one property containing an array - */ -export type ModelWithArray = { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -}; - -/** - * This is a model with one property containing a dictionary - */ -export type ModelWithDictionary = { - prop?: { - [key: string]: string; - }; -}; - -/** - * This is a deprecated model with a deprecated property - * @deprecated - */ -export type DeprecatedModel = { - /** - * This is a deprecated property - * @deprecated - */ - prop?: string; -}; - -/** - * This is a model with one property containing a circular reference - */ -export type ModelWithCircularReference = { - prop?: ModelWithCircularReference; -}; - -/** - * This is a model with one property with a 'one of' relationship - */ -export type CompositionWithOneOf = { - propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; -}; - -/** - * This is a model with one property with a 'one of' relationship where the options are not $ref - */ -export type CompositionWithOneOfAnonymous = { - propA?: { - propA?: string; - } | string | number; -}; - -/** - * Circle - */ -export type ModelCircle = { - kind: string; - radius?: number; -}; - -/** - * Square - */ -export type ModelSquare = { - kind: string; - sideLength?: number; -}; - -/** - * This is a model with one property with a 'one of' relationship where the options are not $ref - */ -export type CompositionWithOneOfDiscriminator = ({ - kind: 'circle'; -} & ModelCircle) | ({ - kind: 'square'; -} & ModelSquare); - -/** - * This is a model with one property with a 'any of' relationship - */ -export type CompositionWithAnyOf = { - propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; -}; - -/** - * This is a model with one property with a 'any of' relationship where the options are not $ref - */ -export type CompositionWithAnyOfAnonymous = { - propA?: { - propA?: string; - } | string | number; -}; - -/** - * This is a model with nested 'any of' property with a type null - */ -export type CompositionWithNestedAnyAndTypeNull = { - propA?: Array | Array; -}; - -export type _3eNum1Период = 'Bird' | 'Dog'; - -export type ConstValue = 'ConstValue'; - -/** - * This is a model with one property with a 'any of' relationship where the options are not $ref - */ -export type CompositionWithNestedAnyOfAndNull = { - propA?: Array<_3eNum1Период | ConstValue> | null; -}; - -/** - * This is a model with one property with a 'one of' relationship - */ -export type CompositionWithOneOfAndNullable = { - propA?: { - boolean?: boolean; - } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; -}; - -/** - * This is a model that contains a simple dictionary within composition - */ -export type CompositionWithOneOfAndSimpleDictionary = { - propA?: boolean | { - [key: string]: number; - }; -}; - -/** - * This is a model that contains a dictionary of simple arrays within composition - */ -export type CompositionWithOneOfAndSimpleArrayDictionary = { - propA?: boolean | { - [key: string]: Array; - }; -}; - -/** - * This is a model that contains a dictionary of complex arrays (composited) within composition - */ -export type CompositionWithOneOfAndComplexArrayDictionary = { - propA?: boolean | { - [key: string]: Array; - }; -}; - -/** - * This is a model with one property with a 'all of' relationship - */ -export type CompositionWithAllOfAndNullable = { - propA?: ({ - boolean?: boolean; - } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; -}; - -/** - * This is a model with one property with a 'any of' relationship - */ -export type CompositionWithAnyOfAndNullable = { - propA?: { - boolean?: boolean; - } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; -}; - -/** - * This is a base model with two simple optional properties - */ -export type CompositionBaseModel = { - firstName?: string; - lastname?: string; -}; - -/** - * This is a model that extends the base model - */ -export type CompositionExtendedModel = CompositionBaseModel & { - age: number; - firstName: string; - lastname: string; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithProperties = { - required: string; - readonly requiredAndReadOnly: string; - requiredAndNullable: string | null; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithNestedProperties = { - readonly first: { - readonly second: { - readonly third: string | null; - } | null; - } | null; -}; - -/** - * This is a model with duplicated properties - */ -export type ModelWithDuplicateProperties = { - prop?: ModelWithString; -}; - -/** - * This is a model with ordered properties - */ -export type ModelWithOrderedProperties = { - zebra?: string; - apple?: string; - hawaii?: string; -}; - -/** - * This is a model with duplicated imports - */ -export type ModelWithDuplicateImports = { - propA?: ModelWithString; - propB?: ModelWithString; - propC?: ModelWithString; -}; - -/** - * This is a model that extends another model - */ -export type ModelThatExtends = ModelWithString & { - propExtendsA?: string; - propExtendsB?: ModelWithString; -}; - -/** - * This is a model that extends another model - */ -export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { - propExtendsC?: string; - propExtendsD?: ModelWithString; -}; - -/** - * This is a model that contains a some patterns - */ -export type ModelWithPattern = { - key: string; - name: string; - readonly enabled?: boolean; - readonly modified?: string; - id?: string; - text?: string; - patternWithSingleQuotes?: string; - patternWithNewline?: string; - patternWithBacktick?: string; -}; - -export type File = { - /** - * Id - */ - readonly id?: string; - /** - * Updated at - */ - readonly updated_at?: string; - /** - * Created at - */ - readonly created_at?: string; - /** - * Mime - */ - mime: string; - /** - * File - */ - readonly file?: string; -}; - -export type Default = { - name?: string; -}; - -export type Pageable = { - page?: number; - size?: number; - sort?: Array; -}; - -/** - * This is a free-form object without additionalProperties. - */ -export type FreeFormObjectWithoutAdditionalProperties = { - [key: string]: unknown; -}; - -/** - * This is a free-form object with additionalProperties: true. - */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = { - [key: string]: unknown; -}; - -/** - * This is a free-form object with additionalProperties: {}. - */ -export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { - [key: string]: unknown; -}; - -export type ModelWithConst = { - String?: 'String'; - number?: 0; - null?: unknown; - withType?: 'Some string'; -}; - -/** - * This is a model with one property and additionalProperties: true - */ -export type ModelWithAdditionalPropertiesEqTrue = { - /** - * This is a simple string property - */ - prop?: string; - [key: string]: unknown | string | undefined; -}; - -export type NestedAnyOfArraysNullable = { - nullableArray?: Array | null; -}; - -export type CompositionWithOneOfAndProperties = ({ - foo: SimpleParameter; -} | { - bar: NonAsciiStringæøåÆøÅöôêÊ字符串; -}) & { - baz: number | null; - qux: number; -}; - -/** - * An object that can be null - */ -export type NullableObject = { - foo?: string; -} | null; - -/** - * Some % character - */ -export type CharactersInDescription = string; - -export type ModelWithNullableObject = { - data?: NullableObject; -}; - -export type ModelWithOneOfEnum = { - foo: 'Bar'; -} | { - foo: 'Baz'; -} | { - foo: 'Qux'; -} | { - content: string; - foo: 'Quux'; -} | { - content: [ - string, - string - ]; - foo: 'Corge'; -}; - -export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; - -export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; - -export type ModelWithNestedArrayEnumsData = { - foo?: Array; - bar?: Array; -}; - -export type ModelWithNestedArrayEnums = { - array_strings?: Array; - data?: ModelWithNestedArrayEnumsData; -}; - -export type ModelWithNestedCompositionEnums = { - foo?: ModelWithNestedArrayEnumsDataFoo; -}; - -export type ModelWithReadOnlyAndWriteOnly = { - foo: string; - readonly bar: string; -}; - -export type ModelWithConstantSizeArray = [ - number, - number -]; - -export type ModelWithAnyOfConstantSizeArray = [ - number | string, - number | string, - number | string -]; - -export type ModelWithPrefixItemsConstantSizeArray = Array; - -export type ModelWithAnyOfConstantSizeArrayNullable = [ - number | null | string, - number | null | string, - number | null | string -]; - -export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ - number | Import, - number | Import -]; - -export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ - number & string, - number & string -]; - -export type ModelWithNumericEnumUnion = { - /** - * Период - */ - value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; -}; - -/** - * Some description with `back ticks` - */ -export type ModelWithBackticksInDescription = { - /** - * The template `that` should be used for parsing and importing the contents of the CSV file. - * - *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

- *
-     * [
-     * {
-     * "resourceType": "Asset",
-     * "identifier": {
-     * "name": "${1}",
-     * "domain": {
-     * "name": "${2}",
-     * "community": {
-     * "name": "Some Community"
-     * }
-     * }
-     * },
-     * "attributes" : {
-     * "00000000-0000-0000-0000-000000003115" : [ {
-     * "value" : "${3}"
-     * } ],
-     * "00000000-0000-0000-0000-000000000222" : [ {
-     * "value" : "${4}"
-     * } ]
-     * }
-     * }
-     * ]
-     * 
- */ - template?: string; -}; - -export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { - baz: number | null; - qux: number; -}; - -/** - * Model used to test deduplication strategy (unused) - */ -export type ParameterSimpleParameterUnused = string; - -/** - * Model used to test deduplication strategy - */ -export type PostServiceWithEmptyTagResponse = string; - -/** - * Model used to test deduplication strategy - */ -export type PostServiceWithEmptyTagResponse2 = string; - -/** - * Model used to test deduplication strategy - */ -export type DeleteFooData = string; - -/** - * Model used to test deduplication strategy - */ -export type DeleteFooData2 = string; - -/** - * Model with restricted keyword name - */ -export type Import = string; - -export type SchemaWithFormRestrictedKeys = { - description?: string; - 'x-enum-descriptions'?: string; - 'x-enum-varnames'?: string; - 'x-enumNames'?: string; - title?: string; - object?: { - description?: string; - 'x-enum-descriptions'?: string; - 'x-enum-varnames'?: string; - 'x-enumNames'?: string; - title?: string; - }; - array?: Array<{ - description?: string; - 'x-enum-descriptions'?: string; - 'x-enum-varnames'?: string; - 'x-enumNames'?: string; - title?: string; - }>; -}; - -/** - * This schema was giving PascalCase transformations a hard time - */ -export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { - /** - * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. - */ - preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; -}; - -/** - * This schema was giving PascalCase transformations a hard time - */ -export type IoK8sApimachineryPkgApisMetaV1Preconditions = { - /** - * Specifies the target ResourceVersion - */ - resourceVersion?: string; - /** - * Specifies the target UID. - */ - uid?: string; -}; - -export type AdditionalPropertiesUnknownIssue = { - [key: string]: string | number; -}; - -export type AdditionalPropertiesUnknownIssue2 = { - [key: string]: string | number; -}; - -export type AdditionalPropertiesUnknownIssue3 = string & { - entries: { - [key: string]: AdditionalPropertiesUnknownIssue; - }; -}; - -export type AdditionalPropertiesIntegerIssue = { - value: number; - [key: string]: number; -}; - -export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; - -export type GenericSchemaDuplicateIssue1SystemBoolean = { - item?: boolean; - error?: string | null; - readonly hasError?: boolean; - data?: { - [key: string]: never; - }; -}; - -export type GenericSchemaDuplicateIssue1SystemString = { - item?: string | null; - error?: string | null; - readonly hasError?: boolean; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithPropertiesWritable = { - required: string; - requiredAndNullable: string | null; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; -}; - -/** - * This is a model that contains a some patterns - */ -export type ModelWithPatternWritable = { - key: string; - name: string; - id?: string; - text?: string; - patternWithSingleQuotes?: string; - patternWithNewline?: string; - patternWithBacktick?: string; -}; - -export type FileWritable = { - /** - * Mime - */ - mime: string; -}; - -export type ModelWithReadOnlyAndWriteOnlyWritable = { - foo: string; - baz: string; -}; - -export type AdditionalPropertiesUnknownIssueWritable = { - [key: string]: string | number; -}; - -export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { - item?: boolean; - error?: string | null; - data?: { - [key: string]: never; - }; -}; - -export type GenericSchemaDuplicateIssue1SystemStringWritable = { - item?: string | null; - error?: string | null; -}; - -/** - * This is a reusable parameter - */ -export type SimpleParameter = string; - -/** - * Parameter with illegal characters - */ -export type XFooBar = ModelWithString; - -export type SimpleRequestBody = ModelWithString; - -export type SimpleFormData = ModelWithString; - -export type ExportData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type PatchApiVbyApiVersionNoTagData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type PatchApiVbyApiVersionNoTagResponses = { - /** - * OK - */ - default: unknown; -}; - -export type ImportData = { - body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type ImportResponses = { - /** - * Success - */ - 200: ModelFromZendesk; - /** - * Default success response - */ - default: ModelWithReadOnlyAndWriteOnly; -}; - -export type ImportResponse = ImportResponses[keyof ImportResponses]; - -export type FooWowData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type FooWowResponses = { - /** - * OK - */ - default: unknown; -}; - -export type ApiVVersionODataControllerCountData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple/$count'; -}; - -export type ApiVVersionODataControllerCountResponses = { - /** - * Success - */ - 200: ModelFromZendesk; -}; - -export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; - -export type GetApiVbyApiVersionSimpleOperationData = { - body?: never; - path: { - /** - * foo in method - */ - foo_param: string; - }; - query?: never; - url: '/api/v{api-version}/simple:operation'; -}; - -export type GetApiVbyApiVersionSimpleOperationErrors = { - /** - * Default error response - */ - default: ModelWithBoolean; -}; - -export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; - -export type GetApiVbyApiVersionSimpleOperationResponses = { - /** - * Response is a simple number - */ - 200: number; -}; - -export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; - -export type DeleteCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type GetCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type HeadCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type OptionsCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PatchCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PostCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PutCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type DeleteFooData3 = { - body?: never; - headers: { - /** - * Parameter with illegal characters - */ - 'x-Foo-Bar': ModelWithString; - }; - path: { - /** - * foo in method - */ - foo_param: string; - /** - * bar in method - */ - BarParam: string; - }; - query?: never; - url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; -}; - -export type CallWithDescriptionsData = { - body?: never; - path?: never; - query?: { - /** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ - parameterWithBreaks?: string; - /** - * Testing backticks in string: `backticks` and ```multiple backticks``` should work - */ - parameterWithBackticks?: string; - /** - * Testing slashes in string: \backwards\\\ and /forwards/// should work - */ - parameterWithSlashes?: string; - /** - * Testing expression placeholders in string: ${expression} should work - */ - parameterWithExpressionPlaceholders?: string; - /** - * Testing quotes in string: 'single quote''' and "double quotes""" should work - */ - parameterWithQuotes?: string; - /** - * Testing reserved characters in string: * inline * and ** inline ** should work - */ - parameterWithReservedCharacters?: string; - }; - url: '/api/v{api-version}/descriptions'; -}; - -export type DeprecatedCallData = { - body?: never; - headers: { - /** - * This parameter is deprecated - * @deprecated - */ - parameter: DeprecatedModel | null; - }; - path?: never; - query?: never; - url: '/api/v{api-version}/parameters/deprecated'; -}; - -export type CallWithParametersData = { - /** - * This is the parameter that goes into the body - */ - body: { - [key: string]: unknown; - } | null; - headers: { - /** - * This is the parameter that goes into the header - */ - parameterHeader: string | null; - }; - path: { - /** - * This is the parameter that goes into the path - */ - parameterPath: string | null; - /** - * api-version should be required in standalone clients - */ - 'api-version': string | null; - }; - query: { - foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; - foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; - /** - * This is the parameter that goes into the query params - */ - cursor: string | null; - }; - url: '/api/v{api-version}/parameters/{parameterPath}'; -}; - -export type CallWithWeirdParameterNamesData = { - /** - * This is the parameter that goes into the body - */ - body: ModelWithString | null; - headers: { - /** - * This is the parameter that goes into the request header - */ - 'parameter.header': string | null; - }; - path: { - /** - * This is the parameter that goes into the path - */ - 'parameter.path.1'?: string; - /** - * This is the parameter that goes into the path - */ - 'parameter-path-2'?: string; - /** - * This is the parameter that goes into the path - */ - 'PARAMETER-PATH-3'?: string; - /** - * api-version should be required in standalone clients - */ - 'api-version': string | null; - }; - query: { - /** - * This is the parameter with a reserved keyword - */ - default?: string; - /** - * This is the parameter that goes into the request query params - */ - 'parameter-query': string | null; - }; - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; -}; - -export type GetCallWithOptionalParamData = { - /** - * This is a required parameter - */ - body: ModelWithOneOfEnum; - path?: never; - query?: { - /** - * This is an optional parameter - */ - page?: number; - }; - url: '/api/v{api-version}/parameters'; -}; - -export type PostCallWithOptionalParamData = { - /** - * This is an optional parameter - */ - body?: { - offset?: number | null; - }; - path?: never; - query: { - /** - * This is a required parameter - */ - parameter: Pageable; - }; - url: '/api/v{api-version}/parameters'; -}; - -export type PostCallWithOptionalParamResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Success - */ - 204: void; -}; - -export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; - -export type PostApiVbyApiVersionRequestBodyData = { - /** - * A reusable request body - */ - body?: SimpleRequestBody; - path?: never; - query?: { - /** - * This is a reusable parameter - */ - parameter?: string; - }; - url: '/api/v{api-version}/requestBody'; -}; - -export type PostApiVbyApiVersionFormDataData = { - /** - * A reusable request body - */ - body?: SimpleFormData; - path?: never; - query?: { - /** - * This is a reusable parameter - */ - parameter?: string; - }; - url: '/api/v{api-version}/formData'; -}; - -export type CallWithDefaultParametersData = { - body?: never; - path?: never; - query?: { - /** - * This is a simple string with default value - */ - parameterString?: string | null; - /** - * This is a simple number with default value - */ - parameterNumber?: number | null; - /** - * This is a simple boolean with default value - */ - parameterBoolean?: boolean | null; - /** - * This is a simple enum with default value - */ - parameterEnum?: 'Success' | 'Warning' | 'Error'; - /** - * This is a simple model with default value - */ - parameterModel?: ModelWithString | null; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type CallWithDefaultOptionalParametersData = { - body?: never; - path?: never; - query?: { - /** - * This is a simple string that is optional with default value - */ - parameterString?: string; - /** - * This is a simple number that is optional with default value - */ - parameterNumber?: number; - /** - * This is a simple boolean that is optional with default value - */ - parameterBoolean?: boolean; - /** - * This is a simple enum that is optional with default value - */ - parameterEnum?: 'Success' | 'Warning' | 'Error'; - /** - * This is a simple model that is optional with default value - */ - parameterModel?: ModelWithString; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type CallToTestOrderOfParamsData = { - body?: never; - path?: never; - query: { - /** - * This is a optional string with default - */ - parameterOptionalStringWithDefault?: string; - /** - * This is a optional string with empty default - */ - parameterOptionalStringWithEmptyDefault?: string; - /** - * This is a optional string with no default - */ - parameterOptionalStringWithNoDefault?: string; - /** - * This is a string with default - */ - parameterStringWithDefault: string; - /** - * This is a string with empty default - */ - parameterStringWithEmptyDefault: string; - /** - * This is a string with no default - */ - parameterStringWithNoDefault: string; - /** - * This is a string that can be null with no default - */ - parameterStringNullableWithNoDefault?: string | null; - /** - * This is a string that can be null with default - */ - parameterStringNullableWithDefault?: string | null; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type DuplicateNameData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName2Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName3Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName4Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type CallWithNoContentResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no-content'; -}; - -export type CallWithNoContentResponseResponses = { - /** - * Success - */ - 204: void; -}; - -export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; - -export type CallWithResponseAndNoContentResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/response-and-no-content'; -}; - -export type CallWithResponseAndNoContentResponseResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Success - */ - 204: void; -}; - -export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; - -export type DummyAData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/a'; -}; - -export type DummyAResponses = { - 200: _400; -}; - -export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; - -export type DummyBData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/b'; -}; - -export type DummyBResponses = { - /** - * Success - */ - 204: void; -}; - -export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; - -export type CallWithResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithResponseResponses = { - default: Import; -}; - -export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; - -export type CallWithDuplicateResponsesData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithDuplicateResponsesErrors = { - /** - * Message for 500 error - */ - 500: ModelWithStringError; - /** - * Message for 501 error - */ - 501: ModelWithStringError; - /** - * Message for 502 error - */ - 502: ModelWithStringError; - /** - * Message for 4XX errors - */ - '4XX': DictionaryWithArray; - /** - * Default error response - */ - default: ModelWithBoolean; -}; - -export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; - -export type CallWithDuplicateResponsesResponses = { - /** - * Message for 200 response - */ - 200: ModelWithBoolean & ModelWithInteger; - /** - * Message for 201 response - */ - 201: ModelWithString; - /** - * Message for 202 response - */ - 202: ModelWithString; -}; - -export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; - -export type CallWithResponsesData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithResponsesErrors = { - /** - * Message for 500 error - */ - 500: ModelWithStringError; - /** - * Message for 501 error - */ - 501: ModelWithStringError; - /** - * Message for 502 error - */ - 502: ModelWithStringError; - /** - * Message for default response - */ - default: ModelWithStringError; -}; - -export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; - -export type CallWithResponsesResponses = { - /** - * Message for 200 response - */ - 200: { - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; - readonly value?: Array; - }; - /** - * Message for 201 response - */ - 201: ModelThatExtends; - /** - * Message for 202 response - */ - 202: ModelThatExtendsExtends; -}; - -export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; - -export type CollectionFormatData = { - body?: never; - path?: never; - query: { - /** - * This is an array parameter that is sent as csv format (comma-separated values) - */ - parameterArrayCSV: Array | null; - /** - * This is an array parameter that is sent as ssv format (space-separated values) - */ - parameterArraySSV: Array | null; - /** - * This is an array parameter that is sent as tsv format (tab-separated values) - */ - parameterArrayTSV: Array | null; - /** - * This is an array parameter that is sent as pipes format (pipe-separated values) - */ - parameterArrayPipes: Array | null; - /** - * This is an array parameter that is sent as multi format (multiple parameter instances) - */ - parameterArrayMulti: Array | null; - }; - url: '/api/v{api-version}/collectionFormat'; -}; - -export type TypesData = { - body?: never; - path?: { - /** - * This is a number parameter - */ - id?: number; - }; - query: { - /** - * This is a number parameter - */ - parameterNumber: number; - /** - * This is a string parameter - */ - parameterString: string | null; - /** - * This is a boolean parameter - */ - parameterBoolean: boolean | null; - /** - * This is an object parameter - */ - parameterObject: { - [key: string]: unknown; - } | null; - /** - * This is an array parameter - */ - parameterArray: Array | null; - /** - * This is a dictionary parameter - */ - parameterDictionary: { - [key: string]: unknown; - } | null; - /** - * This is an enum parameter - */ - parameterEnum: 'Success' | 'Warning' | 'Error'; - }; - url: '/api/v{api-version}/types'; -}; - -export type TypesResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Response is a simple string - */ - 201: string; - /** - * Response is a simple boolean - */ - 202: boolean; - /** - * Response is a simple object - */ - 203: { - [key: string]: unknown; - }; -}; - -export type TypesResponse = TypesResponses[keyof TypesResponses]; - -export type UploadFileData = { - body: Blob | File; - path: { - /** - * api-version should be required in standalone clients - */ - 'api-version': string | null; - }; - query?: never; - url: '/api/v{api-version}/upload'; -}; - -export type UploadFileResponses = { - 200: boolean; -}; - -export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; - -export type FileResponseData = { - body?: never; - path: { - id: string; - /** - * api-version should be required in standalone clients - */ - 'api-version': string; - }; - query?: never; - url: '/api/v{api-version}/file/{id}'; -}; - -export type FileResponseResponses = { - /** - * Success - */ - 200: Blob | File; -}; - -export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; - -export type ComplexTypesData = { - body?: never; - path?: never; - query: { - /** - * Parameter containing object - */ - parameterObject: { - first?: { - second?: { - third?: string; - }; - }; - }; - /** - * Parameter containing reference - */ - parameterReference: ModelWithString; - }; - url: '/api/v{api-version}/complex'; -}; - -export type ComplexTypesErrors = { - /** - * 400 `server` error - */ - 400: unknown; - /** - * 500 server error - */ - 500: unknown; -}; - -export type ComplexTypesResponses = { - /** - * Successful response - */ - 200: Array; -}; - -export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; - -export type MultipartResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multipart'; -}; - -export type MultipartResponseResponses = { - /** - * OK - */ - 200: { - file?: Blob | File; - metadata?: { - foo?: string; - bar?: string; - }; - }; -}; - -export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; - -export type MultipartRequestData = { - body?: { - content?: Blob | File; - data?: ModelWithString | null; - }; - path?: never; - query?: never; - url: '/api/v{api-version}/multipart'; -}; - -export type ComplexParamsData = { - body?: { - readonly key: string | null; - name: string | null; - enabled?: boolean; - type: 'Monkey' | 'Horse' | 'Bird'; - listOfModels?: Array | null; - listOfStrings?: Array | null; - parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; - readonly user?: { - readonly id?: number; - readonly name?: string | null; - }; - }; - path: { - id: number; - /** - * api-version should be required in standalone clients - */ - 'api-version': string; - }; - query?: never; - url: '/api/v{api-version}/complex/{id}'; -}; - -export type ComplexParamsResponses = { - /** - * Success - */ - 200: ModelWithString; -}; - -export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; - -export type CallWithResultFromHeaderData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/header'; -}; - -export type CallWithResultFromHeaderErrors = { - /** - * 400 server error - */ - 400: unknown; - /** - * 500 server error - */ - 500: unknown; -}; - -export type CallWithResultFromHeaderResponses = { - /** - * Successful response - */ - 200: unknown; -}; - -export type TestErrorCodeData = { - body?: never; - path?: never; - query: { - /** - * Status code to return - */ - status: number; - }; - url: '/api/v{api-version}/error'; -}; - -export type TestErrorCodeErrors = { - /** - * Custom message: Internal Server Error - */ - 500: unknown; - /** - * Custom message: Not Implemented - */ - 501: unknown; - /** - * Custom message: Bad Gateway - */ - 502: unknown; - /** - * Custom message: Service Unavailable - */ - 503: unknown; -}; - -export type TestErrorCodeResponses = { - /** - * Custom message: Successful response - */ - 200: unknown; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Data = { - body?: never; - path?: never; - query: { - /** - * Dummy input param - */ - nonAsciiParamæøåÆØÅöôêÊ: number; - }; - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { - /** - * Successful response - */ - 200: Array; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; - -export type PutWithFormUrlEncodedData = { - body: ArrayWithStrings; - path?: never; - query?: never; - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; -}; - -export type ClientOptions = { - baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts index 541563521..2c34871f1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts index 00251fe90..6850887fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/angular-query-experimental'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions, Options> => { - const mutationOptions: MutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions, Options> => { + const mutationOptions: MutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index 6ea52c4b7..e0f7d1b85 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts index 0d7f2d3d0..fda250e99 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/angular-query-experimental'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions> => { - const mutationOptions: MutationOptions> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions> => { + const mutationOptions: MutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts index 0b3f03acd..cc71b7997 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts index abb85ef9a..45e48e977 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Us } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts index 6fe7e3c87..ade1691a2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions, Options> => { - const mutationOptions: UseMutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions, Options> => { + const mutationOptions: UseMutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts index 6ea52c4b7..e0f7d1b85 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts index 1972de130..c4d031451 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions> => { - const mutationOptions: UseMutationOptions> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions> => { + const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts index 497cf4d39..80cf0ec00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): UseMutati } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts index c5f84b545..893e5f52d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts index 56fd9e7bb..bddcb34e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/solid-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions, Options> => { - const mutationOptions: MutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions, Options> => { + const mutationOptions: MutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts index 6ea52c4b7..e0f7d1b85 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts index 22270de65..e150db91b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/solid-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions> => { - const mutationOptions: MutationOptions> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions> => { + const mutationOptions: MutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts index 60c022a12..392d84621 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts index dea24b56c..1086c2202 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts index 47a53470b..822ebb27d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/svelte-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions, Options> => { - const mutationOptions: MutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions, Options> => { + const mutationOptions: MutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index 6ea52c4b7..e0f7d1b85 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts index fa766723e..e883dc537 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/svelte-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions> => { - const mutationOptions: MutationOptions> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions> => { + const mutationOptions: MutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts index 6e7ff65de..98f162beb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts index e36dbe8a8..6c866b7bf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Us } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts index 1b98b18e1..c86860577 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/vue-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions, Options> => { - const mutationOptions: UseMutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions, Options> => { + const mutationOptions: UseMutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts index 6ea52c4b7..e0f7d1b85 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts index c75fd9799..c21b03b97 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/vue-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions> => { - const mutationOptions: UseMutationOptions> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions> => { + const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts index b15071c1c..463216f2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): UseMutati } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/fastify.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/fastify.gen.ts index 03f6f3f43..f7b237f6a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/fastify.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/fastify.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { ImportData, ImportResponses, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseResponses, DummyAResponses, DummyBResponses, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import type { ImportData, ImportResponses, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseResponses, DummyAResponses, DummyBResponses, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; import type { RouteHandler } from 'fastify'; export type RouteHandlers = { @@ -16,8 +16,8 @@ export type RouteHandlers = { Reply: GetApiVbyApiVersionSimpleOperationResponses; }>; deleteFoo: RouteHandler<{ - Headers: DeleteFooData3['headers']; - Params: DeleteFooData3['path']; + Headers: DeleteFooData['headers']; + Params: DeleteFooData['path']; }>; callWithDescriptions: RouteHandler<{ Querystring?: CallWithDescriptionsData['query']; @@ -127,4 +127,4 @@ export type RouteHandlers = { putWithFormUrlEncoded: RouteHandler<{ Body: PutWithFormUrlEncodedData['body']; }>; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts index 39d454abb..ff245bffa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts @@ -2044,4 +2044,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts index 26915de12..e04c6d28c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts @@ -1772,4 +1772,4 @@ export const vPutWithFormUrlEncodedData = v.object({ body: vArrayWithStrings, path: v.optional(v.never()), query: v.optional(v.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/sdk.gen.ts index 265757467..2b1dad28c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { in: 'query', @@ -33,7 +33,7 @@ export const getFoo = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { in: 'cookie', @@ -44,4 +44,4 @@ export const getBar = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/sdk.gen.ts index 02b1b6f72..5f3be6607 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,8 +19,8 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/types.gen.ts index 884795c3f..579f645ec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/types.gen.ts @@ -16,4 +16,4 @@ export type GetFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/sdk.gen.ts index efd68f39a..8e5659281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'bearer', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/sdk.gen.ts index efd68f39a..8e5659281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'bearer', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/sdk.gen.ts index efd68f39a..8e5659281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'bearer', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = export const client = createClient(createConfig({ baseUrl: 'https://foo.com/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/types.gen.ts index fa745dd45..02482e56a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: 'https://foo.com/v1' | `${string}://${string}/v1` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/transformers.gen.ts index 0b520225d..9336baf5a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/transformers.gen.ts @@ -32,4 +32,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const getFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/types.gen.ts index 25ae9771c..e2bd16164 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/types.gen.ts @@ -43,4 +43,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/transformers.gen.ts index 0f3a28be1..62f0dd462 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/transformers.gen.ts @@ -20,4 +20,4 @@ export const getFooResponseTransformer = async (data: any): Promise = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/transformers.gen.ts index 5ad0b923d..fc50ee927 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/transformers.gen.ts @@ -8,4 +8,4 @@ export const getFooResponseTransformer = async (data: any): Promise = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/types.gen.ts index fe0cb7d2e..6c839b35d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/types.gen.ts @@ -109,4 +109,4 @@ export type PostFooWriteResponse = PostFooWriteResponses[keyof PostFooWriteRespo export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/types.gen.ts index 2589e80df..b507475fd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/type-invalid/types.gen.ts @@ -4,4 +4,4 @@ export type Foo = unknown; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts index ca5bd7644..9769db8fa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/valibot.gen.ts @@ -20,4 +20,4 @@ export const vFoo: v.GenericSchema = v.optional(v.union([ v.null() ]), null); -export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), 'baz'); \ No newline at end of file +export const vBaz = v.optional(v.pipe(v.pipe(v.string(), v.regex(/foo\nbar/)), v.readonly()), 'baz'); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts index 2b1ed5a9d..d90f5b3af 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts @@ -12,4 +12,4 @@ export type Baz = Foo & { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/types.gen.ts index 0e69f8bf4..d67d3d123 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true/types.gen.ts @@ -20,4 +20,4 @@ export type Qux = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/types.gen.ts index cb1ed0592..1097aeb99 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-undefined/types.gen.ts @@ -8,4 +8,4 @@ export type Foo = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/types.gen.ts index b133cfb1a..4ac068762 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/types.gen.ts @@ -8,4 +8,4 @@ export type Bar = string; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/valibot.gen.ts index d59c59ed3..46cf09131 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/valibot.gen.ts @@ -6,4 +6,4 @@ export const vBar = v.string(); export const vFoo = v.object({ foo: v.optional(v.pipe(v.array(vBar), v.minLength(1), v.maxLength(2147483647))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/types.gen.ts index be12c3e29..6a8c31d0a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-nested-one-of/types.gen.ts @@ -13,4 +13,4 @@ export type Foo = Array<{ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/sdk.gen.ts index 886e60b1d..d0712e097 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ bodySerializer: null, url: '/foo', ...options, @@ -28,4 +28,4 @@ export const postFoo = (options: Options

= (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts index 3b42909a3..787fcdc28 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base'; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client.gen.ts index 9af8b7347..9ce1b2c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'https://foo.com' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/sdk.gen.ts index 686946526..e497b32cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/sdk.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; export type Options = ClientOptions & { /** @@ -115,7 +115,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return options.client.delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options @@ -419,4 +419,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client.gen.ts index a7fa49acc..430815c63 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen.js'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client/index.js'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/index.ts index ec3da05c8..cea7f39ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen.js'; -export * from './sdk.gen.js'; \ No newline at end of file +export * from './sdk.gen.js'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/sdk.gen.ts index fe9dba4c2..d265aed90 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client/index.js'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen.js'; -import { client as _heyApiClient } from './client.gen.js'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen.js'; +import { client } from './client.gen.js'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts index 6dab9f3e0..2b262d1b4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base'; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client.gen.ts index ff213ad4b..ccd37e81c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'https://foo.com' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/sdk.gen.ts index e9d14d9b7..d7073900a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/sdk.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; export type Options = ClientOptions & { /** @@ -112,7 +112,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return options.client.delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options @@ -405,4 +405,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client.gen.ts index bad221704..8b954d012 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen.js'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client/index.js'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/index.ts index ec3da05c8..cea7f39ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen.js'; -export * from './sdk.gen.js'; \ No newline at end of file +export * from './sdk.gen.js'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/sdk.gen.ts index 648628f59..d3cddea8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client/index.js'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen.js'; -import { client as _heyApiClient } from './client.gen.js'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen.js'; +import { client } from './client.gen.js'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts index 6dab9f3e0..2b262d1b4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base'; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client.gen.ts index ff213ad4b..ccd37e81c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'https://foo.com' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/sdk.gen.ts index e9d14d9b7..d7073900a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/sdk.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; export type Options = ClientOptions & { /** @@ -112,7 +112,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return options.client.delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options @@ -405,4 +405,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client.gen.ts index bad221704..8b954d012 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen.js'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client/index.js'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/index.ts index ec3da05c8..cea7f39ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen.js'; -export * from './sdk.gen.js'; \ No newline at end of file +export * from './sdk.gen.js'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/sdk.gen.ts index 648628f59..d3cddea8e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client/index.js'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen.js'; -import { client as _heyApiClient } from './client.gen.js'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen.js'; +import { client } from './client.gen.js'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts index 3b42909a3..787fcdc28 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base'; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client.gen.ts index 9af8b7347..9ce1b2c40 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'https://foo.com' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client.gen.ts index 64c0080e8..f46dd8f72 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/sdk.gen.ts index 06ac36806..0cd24f1ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type Composable, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).head({ + return (options.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).options({ + return (options.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/sdk.gen.ts index 06ac36806..0cd24f1ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type Composable, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).head({ + return (options.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).options({ + return (options.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/sdk.gen.ts index 06ac36806..0cd24f1ab 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type Composable, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).head({ + return (options.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).options({ + return (options.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/sdk.gen.ts index ea28cfbc7..926a43605 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/sdk.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type Composable, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen'; export type Options = ClientOptions & { /** @@ -112,7 +112,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return options.client.delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options @@ -405,4 +405,4 @@ export const putWithFormUrlEncoded = = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/index.ts index ec3da05c8..cea7f39ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen.js'; -export * from './sdk.gen.js'; \ No newline at end of file +export * from './sdk.gen.js'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/sdk.gen.ts index c864e7df4..bd3b3e8fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type Composable, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client/index.js'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen.js'; -import { client as _heyApiClient } from './client.gen.js'; +import { type Options as ClientOptions, type Composable, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportResponse, ImportData, FooWowData, ApiVVersionODataControllerCountResponse, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseResponse, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseAndNoContentResponseData, DummyAResponse, DummyAData, DummyBResponse, DummyBData, CallWithResponseResponse, CallWithResponseData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithResponsesResponse, CallWithResponsesData, CallWithResponsesError, CollectionFormatData, TypesResponse, TypesData, UploadFileResponse, UploadFileData, FileResponseResponse, FileResponseData, ComplexTypesResponse, ComplexTypesData, MultipartResponseResponse, MultipartResponseData, MultipartRequestData, ComplexParamsResponse, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Response, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from './types.gen.js'; +import { client } from './client.gen.js'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).head({ + return (options.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).options({ + return (options.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).patch({ + return (options.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ + return (options.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/client.gen.ts index 9daa3553e..fece3b1d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/custom-client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/client.gen.ts index 9daa3553e..fece3b1d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/custom-client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts index 6dab9f3e0..2b262d1b4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base'; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/client.gen.ts index d81777bd5..bdea4782e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/custom-client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'https://foo.com' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/client.gen.ts index 9daa3553e..fece3b1d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/custom-client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/sdk.gen.ts index aeafa8ff2..2c08590e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/client.gen.ts index 9daa3553e..fece3b1d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/custom-client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/sdk.gen.ts index aeafa8ff2..2c08590e2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/client.gen.ts index 9daa3553e..fece3b1d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from '@hey-api/custom-client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/sdk.gen.ts index e55907db2..248978c90 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/sdk.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; export type Options = ClientOptions & { /** @@ -112,7 +112,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return options.client.delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options @@ -405,4 +405,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts index 6dab9f3e0..2b262d1b4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base'; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client.gen.ts index ff213ad4b..ccd37e81c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'https://foo.com' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts index 19726b5b8..19189208b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,41 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = + | 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector(...args: ReadonlyArray): ICodegenSymbolSelector { + return [this.meta.name, ...args as ICodegenSymbolSelector]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/sdk.gen.ts index e9d14d9b7..d7073900a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/sdk.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; export type Options = ClientOptions & { /** @@ -112,7 +112,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return options.client.delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options @@ -405,4 +405,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/types.gen.ts index 769d4ee8c..492b157bf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/types.gen.ts @@ -26,4 +26,4 @@ export type PostFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/types.gen.ts index cae8a70b3..1d08e66f1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/const/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/types.gen.ts index e8a09c992..908d5cbec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-binary/types.gen.ts @@ -28,4 +28,4 @@ export type GetBarResponse = GetBarResponses[keyof GetBarResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/sdk.gen.ts index 9f081dd3e..f9331f0a1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,9 +19,9 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/types.gen.ts index 7a4d43642..a2e7d5433 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseURL: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts index 5ea22ca04..3bd1045c3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-all-of/types.gen.ts @@ -64,4 +64,4 @@ export type QuxExtend = FooUnion; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/types.gen.ts index 77b8b2695..a3d6081eb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-any-of/types.gen.ts @@ -29,4 +29,4 @@ export type Quuz = ({ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/types.gen.ts index 5e54fdd48..885b1c7d1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-mapped-many/types.gen.ts @@ -22,4 +22,4 @@ export type Spæcial = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/types.gen.ts index 2604947ad..73005d217 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/discriminator-one-of/types.gen.ts @@ -29,4 +29,4 @@ export type Quuz = ({ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/types.gen.ts index 6c58ee588..727f7529e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/duplicate-null/types.gen.ts @@ -7,4 +7,4 @@ export type WeirdEnum = '' | string | null; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/types.gen.ts index d3fff794b..db360dbbd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-escape/types.gen.ts @@ -8,4 +8,4 @@ export type Bar = "foo'bar" | 'foo"bar'; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/types.gen.ts index 4094079e5..643e6fcae 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-javascript/types.gen.ts @@ -82,4 +82,4 @@ export type PutFooResponse = PutFooResponses[keyof PutFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/types.gen.ts index 0bfbcd423..0679a5270 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline-typescript/types.gen.ts @@ -76,4 +76,4 @@ export type PutFooResponse = PutFooResponses[keyof PutFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/types.gen.ts index a1baf1dab..9163b485e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-inline/types.gen.ts @@ -68,4 +68,4 @@ export type PutFooResponse = PutFooResponses[keyof PutFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/types.gen.ts index 4850cfc02..5ff3b9a6e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-PascalCase/types.gen.ts @@ -57,4 +57,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts index 53ffcb61b..4dbcdea88 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts @@ -57,4 +57,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/types.gen.ts index 9c29e20eb..cfb777368 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-camelCase/types.gen.ts @@ -57,4 +57,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/types.gen.ts index a30f37a34..793b1b847 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-ignore-null/types.gen.ts @@ -56,4 +56,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/types.gen.ts index 8e7c5b91f..15405bb7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-preserve/types.gen.ts @@ -57,4 +57,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/types.gen.ts index 8b93038b4..6b4b9490b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-javascript-snake_case/types.gen.ts @@ -57,4 +57,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/types.gen.ts index c38868ff3..c8965f281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-PascalCase/types.gen.ts @@ -40,4 +40,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts index acd42b7c4..c97aa30dc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts @@ -40,4 +40,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/types.gen.ts index 4e8f07c7a..b840a69cd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-camelCase/types.gen.ts @@ -40,4 +40,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/types.gen.ts index 04b5b9e13..690678694 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-const/types.gen.ts @@ -40,4 +40,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/types.gen.ts index 1b90bdf9c..a81c6479f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-preserve/types.gen.ts @@ -40,4 +40,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/types.gen.ts index a2f4272f6..a4ea1ca03 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values-typescript-snake_case/types.gen.ts @@ -40,4 +40,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/types.gen.ts index c2edaa87d..28d7af1d6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-names-values/types.gen.ts @@ -24,4 +24,4 @@ export type MyFooRef = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/types.gen.ts index 48d0f83a2..0f113e601 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/types.gen.ts @@ -8,4 +8,4 @@ export type Baz = 'foo' | 'bar'; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts index 2e0cabb78..cbaae04e1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/valibot.gen.ts @@ -15,4 +15,4 @@ export const vBar = v.picklist([ export const vBaz = v.picklist([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/types.gen.ts index f09b2f30d..29f6d3874 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/exclude-deprecated/types.gen.ts @@ -18,4 +18,4 @@ export type PostFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/sdk.gen.ts index 13212782f..fdd55cedc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, PatchFooData, PatchFooResponses, PostFooData, PostFooResponses, PutFooData, PutFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,14 +19,14 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/foo', ...options }); }; export const patchFoo = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/foo', ...options, headers: { @@ -37,7 +37,7 @@ export const patchFoo = (options?: Options }; export const postFoo = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/foo', ...options, headers: { @@ -48,7 +48,7 @@ export const postFoo = (options: Options

(options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/foo', ...options, headers: { @@ -56,4 +56,4 @@ export const putFoo = (options: Options BigInt(x)), v.minValue(BigInt('0'), 'Invalid value: Expected uint64 to be >= 0'), v.maxValue(BigInt('18446744073709551615'), 'Invalid value: Expected uint64 to be <= 2^64-1'))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/@tanstack/react-query.gen.ts index f64ca9442..3e8c2dc31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, create, create2, create3 } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { CreateData, Create2Data, Create3Data } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -83,4 +83,4 @@ export const create3Mutation = (options?: Partial>): UseMut } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/sdk.gen.ts index f80a3ecf7..095925019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { CreateData, CreateResponses, Create2Data, Create2Responses, Create3Data, Create3Responses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,22 +19,22 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const create2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/foo', ...options }); }; export const create3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/types.gen.ts index b50eb8e01..3b84b928c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/types.gen.ts @@ -44,4 +44,4 @@ export type Create3Responses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/types.gen.ts index 0c82906bb..653bc66d0 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/negative-property-names/types.gen.ts @@ -18,4 +18,4 @@ export type ReactionRollup = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/types.gen.ts index 05d02f8ae..52d79623a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-all-of/types.gen.ts @@ -12,4 +12,4 @@ export type Foo = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/types.gen.ts index f50aef2b5..626485d0c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-any-of/types.gen.ts @@ -12,4 +12,4 @@ export type Foo = ({ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/types.gen.ts index f50aef2b5..626485d0c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-properties-one-of/types.gen.ts @@ -12,4 +12,4 @@ export type Foo = ({ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/types.gen.ts index d0d07fc7c..bc6d278d9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/object-property-names/types.gen.ts @@ -12,4 +12,4 @@ export type Baz = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/types.gen.ts index 0250e75aa..c8043dbaa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/operation-204/types.gen.ts @@ -22,4 +22,4 @@ export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/@tanstack/react-query.gen.ts index 7738ba5a1..36d23bebd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, postFoo } from '../sdk.gen'; import { queryOptions, infiniteQueryOptions, type InfiniteData, type DefaultError, type UseMutationOptions } from '@tanstack/react-query'; import type { GetFooData, GetFooResponse, PostFooData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -126,4 +126,4 @@ export const postFooMutation = (options?: Partial>): UseMut } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/sdk.gen.ts index de63ffdc0..08f5a8071 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,14 +19,14 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/foo', ...options }); }; export const postFoo = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/foo', ...options, headers: { @@ -34,4 +34,4 @@ export const postFoo = (options: Options

= (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/sdk.gen.ts index 4bbb627bc..c968befbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ querySerializer: { array: { explode: false, @@ -29,4 +29,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/types.gen.ts index e1ed1030b..4639723fb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/types.gen.ts @@ -18,4 +18,4 @@ export type PostFooResponses = { export type ClientOptions = { baseURL: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/sdk.gen.ts index 4bbb627bc..c968befbc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ querySerializer: { array: { explode: false, @@ -29,4 +29,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/types.gen.ts index d69993ad2..7e5ae0357 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/types.gen.ts @@ -18,4 +18,4 @@ export type PostFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/types.gen.ts index a37b6958b..c455f81b4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-tuple/types.gen.ts @@ -23,4 +23,4 @@ export type PostFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/types.gen.ts index 717c93b03..2557e4d7d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pattern-properties/types.gen.ts @@ -53,4 +53,4 @@ export type PostPatternTestResponse = PostPatternTestResponses[keyof PostPattern export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts index 005a668e0..2d5985b31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts index dd1bb7d5b..4ff334ff7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,21 +20,21 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/business/providers/domains', ...options }); } public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/business/providers/domains', ...options }); } public static putBusinessProvidersDomains(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/business/providers/domains', ...options }); @@ -47,7 +47,7 @@ class Providers { export class Business { public static get(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/locations/businesses', ...options }); @@ -57,10 +57,10 @@ export class Business { export class Locations { public static get(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/locations', ...options }); } static business = Business; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts index 568e74efd..133a54ab9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/types.gen.ts @@ -82,4 +82,4 @@ export type GetResponse = GetResponses[keyof GetResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts index 4e3603d9c..55e9ad934 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts @@ -2134,4 +2134,4 @@ export const Generic_Schema_Duplicate_Issue_1_System_String_WritableSchema = { } }, additionalProperties: false -} as const; \ No newline at end of file +} as const; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client.gen.ts index 14f2d878c..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -15,4 +15,4 @@ export type CreateClientConfig = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/sdk.gen.ts index ebc3a8457..4cf0ca9c4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base', throwOnError: true -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts index e54e0318f..6d229fd5d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (option * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options: }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = }; export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (op }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = (o }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Options }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opti }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (optio ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts index 20c92fc95..5c161731c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/sdk.gen.ts @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; -import { postFooResponseTransformer } from './transformers.gen'; -import { vPostFooResponse } from './valibot.gen'; +import { vPostFooData, vPostFooResponse } from './valibot.gen'; import * as v from 'valibot'; -import { client as _heyApiClient } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,7 +22,10 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ + requestValidator: async (data) => { + return await v.parseAsync(vPostFooData, data); + }, responseTransformer: postFooResponseTransformer, responseValidator: async (data) => { return await v.parseAsync(vPostFooResponse, data); @@ -30,4 +33,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts index 419690a91..cc9dcf841 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/transformers.gen.ts @@ -10,4 +10,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const postFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts index 8250a422d..ba800b837 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/types.gen.ts @@ -33,4 +33,4 @@ export type UserId = TypeID<'user'>; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts index e49e2e14e..a030d9354 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/valibot.gen.ts @@ -25,4 +25,4 @@ export const vPostFooData = v.object({ /** * OK */ -export const vPostFooResponse = vFoo; \ No newline at end of file +export const vPostFooResponse = vFoo; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts index 67d605869..9067c31ee 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/sdk.gen.ts @@ -1,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { PostFooData, PostFooResponses } from './types.gen'; import { zPostFooData, zPostFooResponse } from './zod.gen'; import { postFooResponseTransformer } from './transformers.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -21,7 +21,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ requestValidator: async (data) => { return await zPostFooData.parseAsync(data); }, @@ -32,4 +32,4 @@ export const postFoo = (options?: Options< url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts index 419690a91..cc9dcf841 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/transformers.gen.ts @@ -10,4 +10,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const postFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts index 8250a422d..ba800b837 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/types.gen.ts @@ -33,4 +33,4 @@ export type UserId = TypeID<'user'>; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts index bfee2ff85..477553d5c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts index 4c85ab89a..7c3bc951c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/types.gen.ts @@ -163,4 +163,4 @@ export type PutFooWriteResponse = PutFooWriteResponses[keyof PutFooWriteResponse export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts index c9f00d65e..ee224cabf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/types.gen.ts @@ -139,4 +139,4 @@ export type PutFooWriteResponse = PutFooWriteResponses[keyof PutFooWriteResponse export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts index ce759964c..5e6302120 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/@pinia/colada.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -18,7 +18,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (tags) { params.tags = tags as unknown as undefined; } @@ -194,7 +194,7 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { +export const deleteFooMutation = (options: Options): UseMutationOptions, Error> => { return { mutation: async (fnOptions) => { const { data } = await deleteFoo({ @@ -692,4 +692,4 @@ export const putWithFormUrlEncodedMutation = (options: Options = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts deleted file mode 100644 index 27d358cc3..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/CollectionFormat.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, collectionFormat } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { CollectionFormatData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const collectionFormatQueryKey = (options: Options) => createQueryKey('collectionFormat', options); - -export const collectionFormatQuery = (options: Options): UseQueryOptions => { - return { - key: collectionFormatQueryKey(options), - query: async (context) => { - const { data } = await collectionFormat({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts deleted file mode 100644 index 2d73a2a25..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Complex.gen.ts +++ /dev/null @@ -1,69 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, complexTypes, complexParams } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ComplexTypesData, ComplexTypesResponse, ComplexParamsData, ComplexParamsResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const complexTypesQueryKey = (options: Options) => createQueryKey('complexTypes', options); - -export const complexTypesQuery = (options: Options): UseQueryOptions => { - return { - key: complexTypesQueryKey(options), - query: async (context) => { - const { data } = await complexTypes({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const complexParamsMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await complexParams({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts deleted file mode 100644 index 1b5096aea..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Defaults.gen.ts +++ /dev/null @@ -1,82 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithDefaultParametersQueryKey = (options?: Options) => createQueryKey('callWithDefaultParameters', options); - -export const callWithDefaultParametersQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithDefaultParametersQueryKey(options), - query: async (context) => { - const { data } = await callWithDefaultParameters({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithDefaultOptionalParametersMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDefaultOptionalParameters({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callToTestOrderOfParamsMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callToTestOrderOfParams({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts deleted file mode 100644 index b35ad56ae..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Deprecated.gen.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, deprecatedCall } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { DeprecatedCallData } from '../../types.gen'; - -/** - * @deprecated - */ -export const deprecatedCallMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await deprecatedCall({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts deleted file mode 100644 index 05f30e6d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Descriptions.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithDescriptions } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { CallWithDescriptionsData } from '../../types.gen'; - -export const callWithDescriptionsMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDescriptions({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts deleted file mode 100644 index ed05f186b..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Duplicate.gen.ts +++ /dev/null @@ -1,95 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, duplicateName, duplicateName2, duplicateName3, duplicateName4 } from '../../sdk.gen'; -import type { UseMutationOptions, _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export const duplicateNameMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const duplicateName2QueryKey = (options?: Options) => createQueryKey('duplicateName2', options); - -export const duplicateName2Query = (options?: Options): UseQueryOptions => { - return { - key: duplicateName2QueryKey(options), - query: async (context) => { - const { data } = await duplicateName2({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const duplicateName3Mutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName3({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const duplicateName4Mutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await duplicateName4({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts deleted file mode 100644 index 90dc048d7..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Error.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, testErrorCode } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { TestErrorCodeData } from '../../types.gen'; - -export const testErrorCodeMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await testErrorCode({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts deleted file mode 100644 index 49a263c90..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FileResponse.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, fileResponse } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { FileResponseData, FileResponseResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const fileResponseQueryKey = (options: Options) => createQueryKey('fileResponse', options); - -export const fileResponseQuery = (options: Options): UseQueryOptions => { - return { - key: fileResponseQueryKey(options), - query: async (context) => { - const { data } = await fileResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts deleted file mode 100644 index 64656dee0..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/FormData.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, postApiVbyApiVersionFormData } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { PostApiVbyApiVersionFormDataData } from '../../types.gen'; - -export const postApiVbyApiVersionFormDataMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postApiVbyApiVersionFormData({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts deleted file mode 100644 index 2100075e4..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Header.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithResultFromHeader } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { CallWithResultFromHeaderData } from '../../types.gen'; - -export const callWithResultFromHeaderMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithResultFromHeader({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts deleted file mode 100644 index 1bf294ca7..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/MultipleTags1.gen.ts +++ /dev/null @@ -1,72 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, dummyA, dummyB } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DummyAData, DummyAResponse, DummyBData, DummyBResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const dummyAQueryKey = (options?: Options) => createQueryKey('dummyA', options); - -export const dummyAQuery = (options?: Options): UseQueryOptions => { - return { - key: dummyAQueryKey(options), - query: async (context) => { - const { data } = await dummyA({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const dummyBQueryKey = (options?: Options) => createQueryKey('dummyB', options); - -export const dummyBQuery = (options?: Options): UseQueryOptions => { - return { - key: dummyBQueryKey(options), - query: async (context) => { - const { data } = await dummyB({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" "b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" deleted file mode 100644 index a01de3df0..000000000 --- "a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Non-Ascii-\303\246\303\270\303\245\303\206\303\230\303\205\303\266\303\264\303\252\303\212.gen.ts" +++ /dev/null @@ -1,34 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../types.gen'; - -export const nonAsciiæøåÆøÅöôêÊ字符串Mutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await nonAsciiæøåÆøÅöôêÊ字符串({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -/** - * Login User - */ -export const putWithFormUrlEncodedMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await putWithFormUrlEncoded({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts deleted file mode 100644 index 6c54734b5..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Parameters.gen.ts +++ /dev/null @@ -1,108 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, deleteFoo, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam } from '../../sdk.gen'; -import type { UseMutationOptions, _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export const deleteFooMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await deleteFoo({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithParametersMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithParameters({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithWeirdParameterNamesMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithWeirdParameterNames({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const getCallWithOptionalParamQueryKey = (options: Options) => createQueryKey('getCallWithOptionalParam', options); - -export const getCallWithOptionalParamQuery = (options: Options): UseQueryOptions => { - return { - key: getCallWithOptionalParamQueryKey(options), - query: async (context) => { - const { data } = await getCallWithOptionalParam({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const postCallWithOptionalParamMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postCallWithOptionalParam({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts deleted file mode 100644 index 843f64910..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/RequestBody.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, postApiVbyApiVersionRequestBody } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { PostApiVbyApiVersionRequestBodyData } from '../../types.gen'; - -export const postApiVbyApiVersionRequestBodyMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postApiVbyApiVersionRequestBody({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts deleted file mode 100644 index fb4f50eab..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Response.gen.ts +++ /dev/null @@ -1,98 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithResponseAndNoContentResponse, callWithResponse, callWithDuplicateResponses, callWithResponses } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithResponseAndNoContentResponseQueryKey = (options?: Options) => createQueryKey('callWithResponseAndNoContentResponse', options); - -export const callWithResponseAndNoContentResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithResponseAndNoContentResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithResponseAndNoContentResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithResponseQueryKey = (options?: Options) => createQueryKey('callWithResponse', options); - -export const callWithResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithDuplicateResponsesMutation = (options?: Options): UseMutationOptions, CallWithDuplicateResponsesError> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithDuplicateResponses({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const callWithResponsesMutation = (options?: Options): UseMutationOptions, CallWithResponsesError> => { - return { - mutation: async (fnOptions) => { - const { data } = await callWithResponses({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts deleted file mode 100644 index e4d9c13d7..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Simple.gen.ts +++ /dev/null @@ -1,124 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, apiVVersionODataControllerCount, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const apiVVersionODataControllerCountQueryKey = (options?: Options) => createQueryKey('apiVVersionODataControllerCount', options); - -export const apiVVersionODataControllerCountQuery = (options?: Options): UseQueryOptions => { - return { - key: apiVVersionODataControllerCountQueryKey(options), - query: async (context) => { - const { data } = await apiVVersionODataControllerCount({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const deleteCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await deleteCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const getCallWithoutParametersAndResponseQueryKey = (options?: Options) => createQueryKey('getCallWithoutParametersAndResponse', options); - -export const getCallWithoutParametersAndResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: getCallWithoutParametersAndResponseQueryKey(options), - query: async (context) => { - const { data } = await getCallWithoutParametersAndResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const patchCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await patchCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const postCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await postCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const putCallWithoutParametersAndResponseMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await putCallWithoutParametersAndResponse({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts deleted file mode 100644 index 822ebd8fe..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Types.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, types } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { TypesData, TypesResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const typesQueryKey = (options: Options) => createQueryKey('types', options); - -export const typesQuery = (options: Options): UseQueryOptions => { - return { - key: typesQueryKey(options), - query: async (context) => { - const { data } = await types({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts deleted file mode 100644 index 444d8f9ec..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/Upload.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, uploadFile } from '../../sdk.gen'; -import type { UseMutationOptions } from '@pinia/colada'; -import type { UploadFileData, UploadFileResponse } from '../../types.gen'; - -export const uploadFileMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await uploadFile({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts deleted file mode 100644 index f11c6546a..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/default.gen.ts +++ /dev/null @@ -1,111 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, getApiVbyApiVersionSimpleOperation } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationError, GetApiVbyApiVersionSimpleOperationResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const exportQueryKey = (options?: Options) => createQueryKey('export', options); - -export const exportQuery = (options?: Options): UseQueryOptions => { - return { - key: exportQueryKey(options), - query: async (context) => { - const { data } = await export_({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const patchApiVbyApiVersionNoTagMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await patchApiVbyApiVersionNoTag({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const importMutation = (options: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await import_({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const fooWowMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await fooWow({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; - -export const getApiVbyApiVersionSimpleOperationQueryKey = (options: Options) => createQueryKey('getApiVbyApiVersionSimpleOperation', options); - -export const getApiVbyApiVersionSimpleOperationQuery = (options: Options): UseQueryOptions => { - return { - key: getApiVbyApiVersionSimpleOperationQueryKey(options), - query: async (context) => { - const { data } = await getApiVbyApiVersionSimpleOperation({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts deleted file mode 100644 index e47a721b5..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/multipart.gen.ts +++ /dev/null @@ -1,69 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, multipartResponse, multipartRequest } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; -import type { MultipartResponseData, MultipartResponseResponse, MultipartRequestData } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const multipartResponseQueryKey = (options?: Options) => createQueryKey('multipartResponse', options); - -export const multipartResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: multipartResponseQueryKey(options), - query: async (context) => { - const { data } = await multipartResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; - -export const multipartRequestMutation = (options?: Options): UseMutationOptions, Error> => { - return { - mutation: async (fnOptions) => { - const { data } = await multipartRequest({ - ...options, - ...fnOptions, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/noContent.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/noContent.gen.ts deleted file mode 100644 index f808551bc..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/@pinia/colada/noContent.gen.ts +++ /dev/null @@ -1,56 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options, callWithNoContentResponse } from '../../sdk.gen'; -import type { _JSONValue, UseQueryOptions } from '@pinia/colada'; -import type { CallWithNoContentResponseData, CallWithNoContentResponseResponse } from '../../types.gen'; -import { client as _heyApiClient } from '../../client.gen'; - -export type QueryKey = [ - Pick & { - _id: string; - baseUrl?: _JSONValue; - headers?: _JSONValue; - query?: _JSONValue; - tags?: _JSONValue; - } -]; - -const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ - QueryKey[0] -] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; - if (tags) { - params.tags = tags as unknown as undefined; - } - if (options?.body) { - params.body = options.body; - } - if (options?.headers) { - params.headers = options.headers as unknown as undefined; - } - if (options?.path) { - params.path = options.path; - } - if (options?.query) { - params.query = options.query as unknown as undefined; - } - return [ - params - ]; -}; - -export const callWithNoContentResponseQueryKey = (options?: Options) => createQueryKey('callWithNoContentResponse', options); - -export const callWithNoContentResponseQuery = (options?: Options): UseQueryOptions => { - return { - key: callWithNoContentResponseQueryKey(options), - query: async (context) => { - const { data } = await callWithNoContentResponse({ - ...options, - ...context, - throwOnError: true - }); - return data; - } - }; -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client.gen.ts deleted file mode 100644 index 14f2d878c..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client.gen.ts +++ /dev/null @@ -1,18 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig = (override?: Config) => Config & T>; - -export const client = createClient(createConfig({ - baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts deleted file mode 100644 index f68339318..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ /dev/null @@ -1,267 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { createSseClient } from '../core/serverSentEvents.gen'; -import type { HttpMethod } from '../core/types.gen'; -import type { - Client, - Config, - RequestOptions, - ResolvedRequestOptions, -} from './types.gen'; -import { - buildUrl, - createConfig, - createInterceptors, - getParseAs, - mergeConfigs, - mergeHeaders, - setAuthParams, -} from './utils.gen'; - -type ReqInit = Omit & { - body?: any; - headers: ReturnType; -}; - -export const createClient = (config: Config = {}): Client => { - let _config = mergeConfigs(createConfig(), config); - - const getConfig = (): Config => ({ ..._config }); - - const setConfig = (config: Config): Config => { - _config = mergeConfigs(_config, config); - return getConfig(); - }; - - const interceptors = createInterceptors< - Request, - Response, - unknown, - ResolvedRequestOptions - >(); - - const beforeRequest = async (options: RequestOptions) => { - const opts = { - ..._config, - ...options, - fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, - headers: mergeHeaders(_config.headers, options.headers), - serializedBody: undefined, - }; - - if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); - } - - if (opts.requestValidator) { - await opts.requestValidator(opts); - } - - if (opts.body && opts.bodySerializer) { - opts.serializedBody = opts.bodySerializer(opts.body); - } - - // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { - opts.headers.delete('Content-Type'); - } - - const url = buildUrl(opts); - - return { opts, url }; - }; - - const request: Client['request'] = async (options) => { - // @ts-expect-error - const { opts, url } = await beforeRequest(options); - const requestInit: ReqInit = { - redirect: 'follow', - ...opts, - body: opts.serializedBody, - }; - - let request = new Request(url, requestInit); - - for (const fn of interceptors.request._fns) { - if (fn) { - request = await fn(request, opts); - } - } - - // fetch must be assigned here, otherwise it would throw the error: - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation - const _fetch = opts.fetch!; - let response = await _fetch(request); - - for (const fn of interceptors.response._fns) { - if (fn) { - response = await fn(response, request, opts); - } - } - - const result = { - request, - response, - }; - - if (response.ok) { - const parseAs = - (opts.parseAs === 'auto' - ? getParseAs(response.headers.get('Content-Type')) - : opts.parseAs) ?? 'json'; - - if ( - response.status === 204 || - response.headers.get('Content-Length') === '0' - ) { - let emptyData: any; - switch (parseAs) { - case 'arrayBuffer': - case 'blob': - case 'text': - emptyData = await response[parseAs](); - break; - case 'formData': - emptyData = new FormData(); - break; - case 'stream': - emptyData = response.body; - break; - case 'json': - default: - emptyData = {}; - break; - } - return opts.responseStyle === 'data' - ? emptyData - : { - data: emptyData, - ...result, - }; - } - - let data: any; - switch (parseAs) { - case 'arrayBuffer': - case 'blob': - case 'formData': - case 'json': - case 'text': - data = await response[parseAs](); - break; - case 'stream': - return opts.responseStyle === 'data' - ? response.body - : { - data: response.body, - ...result, - }; - } - - if (parseAs === 'json') { - if (opts.responseValidator) { - await opts.responseValidator(data); - } - - if (opts.responseTransformer) { - data = await opts.responseTransformer(data); - } - } - - return opts.responseStyle === 'data' - ? data - : { - data, - ...result, - }; - } - - const textError = await response.text(); - let jsonError: unknown; - - try { - jsonError = JSON.parse(textError); - } catch { - // noop - } - - const error = jsonError ?? textError; - let finalError = error; - - for (const fn of interceptors.error._fns) { - if (fn) { - finalError = (await fn(error, response, request, opts)) as string; - } - } - - finalError = finalError || ({} as string); - - if (opts.throwOnError) { - throw finalError; - } - - // TODO: we probably want to return error and improve types - return opts.responseStyle === 'data' - ? undefined - : { - error: finalError, - ...result, - }; - }; - - const makeMethodFn = - (method: Uppercase) => (options: RequestOptions) => - request({ ...options, method }); - - const makeSseFn = - (method: Uppercase) => async (options: RequestOptions) => { - const { opts, url } = await beforeRequest(options); - return createSseClient({ - ...opts, - body: opts.body as BodyInit | null | undefined, - headers: opts.headers as unknown as Record, - method, - onRequest: async (url, init) => { - let request = new Request(url, init); - for (const fn of interceptors.request._fns) { - if (fn) { - request = await fn(request, opts); - } - } - return request; - }, - url, - }); - }; - - return { - buildUrl, - connect: makeMethodFn('CONNECT'), - delete: makeMethodFn('DELETE'), - get: makeMethodFn('GET'), - getConfig, - head: makeMethodFn('HEAD'), - interceptors, - options: makeMethodFn('OPTIONS'), - patch: makeMethodFn('PATCH'), - post: makeMethodFn('POST'), - put: makeMethodFn('PUT'), - request, - setConfig, - sse: { - connect: makeSseFn('CONNECT'), - delete: makeSseFn('DELETE'), - get: makeSseFn('GET'), - head: makeSseFn('HEAD'), - options: makeSseFn('OPTIONS'), - patch: makeSseFn('PATCH'), - post: makeSseFn('POST'), - put: makeSseFn('PUT'), - trace: makeSseFn('TRACE'), - }, - trace: makeMethodFn('TRACE'), - } as Client; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/index.ts deleted file mode 100644 index 318a84b6a..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -export type { Auth } from '../core/auth.gen'; -export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; -export { - formDataBodySerializer, - jsonBodySerializer, - urlSearchParamsBodySerializer, -} from '../core/bodySerializer.gen'; -export { buildClientParams } from '../core/params.gen'; -export { createClient } from './client.gen'; -export type { - Client, - ClientOptions, - Config, - CreateClientConfig, - Options, - OptionsLegacyParser, - RequestOptions, - RequestResult, - ResolvedRequestOptions, - ResponseStyle, - TDataShape, -} from './types.gen'; -export { createConfig, mergeHeaders } from './utils.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts deleted file mode 100644 index 1a005b51e..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts +++ /dev/null @@ -1,268 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Auth } from '../core/auth.gen'; -import type { - ServerSentEventsOptions, - ServerSentEventsResult, -} from '../core/serverSentEvents.gen'; -import type { - Client as CoreClient, - Config as CoreConfig, -} from '../core/types.gen'; -import type { Middleware } from './utils.gen'; - -export type ResponseStyle = 'data' | 'fields'; - -export interface Config - extends Omit, - CoreConfig { - /** - * Base URL for all requests made by this client. - */ - baseUrl?: T['baseUrl']; - /** - * Fetch API implementation. You can use this option to provide a custom - * fetch instance. - * - * @default globalThis.fetch - */ - fetch?: typeof fetch; - /** - * Please don't use the Fetch client for Next.js applications. The `next` - * options won't have any effect. - * - * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. - */ - next?: never; - /** - * Return the response data parsed in a specified format. By default, `auto` - * will infer the appropriate method from the `Content-Type` response header. - * You can override this behavior with any of the {@link Body} methods. - * Select `stream` if you don't want to parse response data at all. - * - * @default 'auto' - */ - parseAs?: - | 'arrayBuffer' - | 'auto' - | 'blob' - | 'formData' - | 'json' - | 'stream' - | 'text'; - /** - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ - responseStyle?: ResponseStyle; - /** - * Throw an error instead of returning it in the response? - * - * @default false - */ - throwOnError?: T['throwOnError']; -} - -export interface RequestOptions< - TData = unknown, - TResponseStyle extends ResponseStyle = 'fields', - ThrowOnError extends boolean = boolean, - Url extends string = string, -> extends Config<{ - responseStyle: TResponseStyle; - throwOnError: ThrowOnError; - }>, - Pick< - ServerSentEventsOptions, - | 'onSseError' - | 'onSseEvent' - | 'sseDefaultRetryDelay' - | 'sseMaxRetryAttempts' - | 'sseMaxRetryDelay' - > { - /** - * Any body that you want to add to your request. - * - * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} - */ - body?: unknown; - path?: Record; - query?: Record; - /** - * Security mechanism(s) to use for the request. - */ - security?: ReadonlyArray; - url: Url; -} - -export interface ResolvedRequestOptions< - TResponseStyle extends ResponseStyle = 'fields', - ThrowOnError extends boolean = boolean, - Url extends string = string, -> extends RequestOptions { - serializedBody?: string; -} - -export type RequestResult< - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = boolean, - TResponseStyle extends ResponseStyle = 'fields', -> = ThrowOnError extends true - ? Promise< - TResponseStyle extends 'data' - ? TData extends Record - ? TData[keyof TData] - : TData - : { - data: TData extends Record - ? TData[keyof TData] - : TData; - request: Request; - response: Response; - } - > - : Promise< - TResponseStyle extends 'data' - ? - | (TData extends Record - ? TData[keyof TData] - : TData) - | undefined - : ( - | { - data: TData extends Record - ? TData[keyof TData] - : TData; - error: undefined; - } - | { - data: undefined; - error: TError extends Record - ? TError[keyof TError] - : TError; - } - ) & { - request: Request; - response: Response; - } - >; - -export interface ClientOptions { - baseUrl?: string; - responseStyle?: ResponseStyle; - throwOnError?: boolean; -} - -type MethodFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'>, -) => RequestResult; - -type SseFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'>, -) => Promise>; - -type RequestFn = < - TData = unknown, - TError = unknown, - ThrowOnError extends boolean = false, - TResponseStyle extends ResponseStyle = 'fields', ->( - options: Omit, 'method'> & - Pick< - Required>, - 'method' - >, -) => RequestResult; - -type BuildUrlFn = < - TData extends { - body?: unknown; - path?: Record; - query?: Record; - url: string; - }, ->( - options: Pick & Options, -) => string; - -export type Client = CoreClient< - RequestFn, - Config, - MethodFn, - BuildUrlFn, - SseFn -> & { - interceptors: Middleware; -}; - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig = ( - override?: Config, -) => Config & T>; - -export interface TDataShape { - body?: unknown; - headers?: unknown; - path?: unknown; - query?: unknown; - url: string; -} - -type OmitKeys = Pick>; - -export type Options< - TData extends TDataShape = TDataShape, - ThrowOnError extends boolean = boolean, - TResponse = unknown, - TResponseStyle extends ResponseStyle = 'fields', -> = OmitKeys< - RequestOptions, - 'body' | 'path' | 'query' | 'url' -> & - Omit; - -export type OptionsLegacyParser< - TData = unknown, - ThrowOnError extends boolean = boolean, - TResponseStyle extends ResponseStyle = 'fields', -> = TData extends { body?: any } - ? TData extends { headers?: any } - ? OmitKeys< - RequestOptions, - 'body' | 'headers' | 'url' - > & - TData - : OmitKeys< - RequestOptions, - 'body' | 'url' - > & - TData & - Pick, 'headers'> - : TData extends { headers?: any } - ? OmitKeys< - RequestOptions, - 'headers' | 'url' - > & - TData & - Pick, 'body'> - : OmitKeys, 'url'> & - TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts deleted file mode 100644 index a47509522..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/utils.gen.ts +++ /dev/null @@ -1,327 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { getAuthToken } from '../core/auth.gen'; -import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; -import { jsonBodySerializer } from '../core/bodySerializer.gen'; -import { - serializeArrayParam, - serializeObjectParam, - serializePrimitiveParam, -} from '../core/pathSerializer.gen'; -import { getUrl } from '../core/utils.gen'; -import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; - -export const createQuerySerializer = ({ - allowReserved, - array, - object, -}: QuerySerializerOptions = {}) => { - const querySerializer = (queryParams: T) => { - const search: string[] = []; - if (queryParams && typeof queryParams === 'object') { - for (const name in queryParams) { - const value = queryParams[name]; - - if (value === undefined || value === null) { - continue; - } - - if (Array.isArray(value)) { - const serializedArray = serializeArrayParam({ - allowReserved, - explode: true, - name, - style: 'form', - value, - ...array, - }); - if (serializedArray) search.push(serializedArray); - } else if (typeof value === 'object') { - const serializedObject = serializeObjectParam({ - allowReserved, - explode: true, - name, - style: 'deepObject', - value: value as Record, - ...object, - }); - if (serializedObject) search.push(serializedObject); - } else { - const serializedPrimitive = serializePrimitiveParam({ - allowReserved, - name, - value: value as string, - }); - if (serializedPrimitive) search.push(serializedPrimitive); - } - } - } - return search.join('&'); - }; - return querySerializer; -}; - -/** - * Infers parseAs value from provided Content-Type header. - */ -export const getParseAs = ( - contentType: string | null, -): Exclude => { - if (!contentType) { - // If no Content-Type header is provided, the best we can do is return the raw response body, - // which is effectively the same as the 'stream' option. - return 'stream'; - } - - const cleanContent = contentType.split(';')[0]?.trim(); - - if (!cleanContent) { - return; - } - - if ( - cleanContent.startsWith('application/json') || - cleanContent.endsWith('+json') - ) { - return 'json'; - } - - if (cleanContent === 'multipart/form-data') { - return 'formData'; - } - - if ( - ['application/', 'audio/', 'image/', 'video/'].some((type) => - cleanContent.startsWith(type), - ) - ) { - return 'blob'; - } - - if (cleanContent.startsWith('text/')) { - return 'text'; - } - - return; -}; - -const checkForExistence = ( - options: Pick & { - headers: Headers; - }, - name?: string, -): boolean => { - if (!name) { - return false; - } - if ( - options.headers.has(name) || - options.query?.[name] || - options.headers.get('Cookie')?.includes(`${name}=`) - ) { - return true; - } - return false; -}; - -export const setAuthParams = async ({ - security, - ...options -}: Pick, 'security'> & - Pick & { - headers: Headers; - }) => { - for (const auth of security) { - if (checkForExistence(options, auth.name)) { - continue; - } - - const token = await getAuthToken(auth, options.auth); - - if (!token) { - continue; - } - - const name = auth.name ?? 'Authorization'; - - switch (auth.in) { - case 'query': - if (!options.query) { - options.query = {}; - } - options.query[name] = token; - break; - case 'cookie': - options.headers.append('Cookie', `${name}=${token}`); - break; - case 'header': - default: - options.headers.set(name, token); - break; - } - } -}; - -export const buildUrl: Client['buildUrl'] = (options) => - getUrl({ - baseUrl: options.baseUrl as string, - path: options.path, - query: options.query, - querySerializer: - typeof options.querySerializer === 'function' - ? options.querySerializer - : createQuerySerializer(options.querySerializer), - url: options.url, - }); - -export const mergeConfigs = (a: Config, b: Config): Config => { - const config = { ...a, ...b }; - if (config.baseUrl?.endsWith('/')) { - config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); - } - config.headers = mergeHeaders(a.headers, b.headers); - return config; -}; - -export const mergeHeaders = ( - ...headers: Array['headers'] | undefined> -): Headers => { - const mergedHeaders = new Headers(); - for (const header of headers) { - if (!header || typeof header !== 'object') { - continue; - } - - const iterator = - header instanceof Headers ? header.entries() : Object.entries(header); - - for (const [key, value] of iterator) { - if (value === null) { - mergedHeaders.delete(key); - } else if (Array.isArray(value)) { - for (const v of value) { - mergedHeaders.append(key, v as string); - } - } else if (value !== undefined) { - // assume object headers are meant to be JSON stringified, i.e. their - // content value in OpenAPI specification is 'application/json' - mergedHeaders.set( - key, - typeof value === 'object' ? JSON.stringify(value) : (value as string), - ); - } - } - } - return mergedHeaders; -}; - -type ErrInterceptor = ( - error: Err, - response: Res, - request: Req, - options: Options, -) => Err | Promise; - -type ReqInterceptor = ( - request: Req, - options: Options, -) => Req | Promise; - -type ResInterceptor = ( - response: Res, - request: Req, - options: Options, -) => Res | Promise; - -class Interceptors { - _fns: (Interceptor | null)[]; - - constructor() { - this._fns = []; - } - - clear() { - this._fns = []; - } - - getInterceptorIndex(id: number | Interceptor): number { - if (typeof id === 'number') { - return this._fns[id] ? id : -1; - } else { - return this._fns.indexOf(id); - } - } - exists(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - return !!this._fns[index]; - } - - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; - } - } - - update(id: number | Interceptor, fn: Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; - return id; - } else { - return false; - } - } - - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; - } -} - -// `createInterceptors()` response, meant for external use as it does not -// expose internals -export interface Middleware { - error: Pick< - Interceptors>, - 'eject' | 'use' - >; - request: Pick>, 'eject' | 'use'>; - response: Pick< - Interceptors>, - 'eject' | 'use' - >; -} - -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ - error: new Interceptors>(), - request: new Interceptors>(), - response: new Interceptors>(), -}); - -const defaultQuerySerializer = createQuerySerializer({ - allowReserved: false, - array: { - explode: true, - style: 'form', - }, - object: { - explode: true, - style: 'deepObject', - }, -}); - -const defaultHeaders = { - 'Content-Type': 'application/json', -}; - -export const createConfig = ( - override: Config & T> = {}, -): Config & T> => ({ - ...jsonBodySerializer, - headers: defaultHeaders, - parseAs: 'auto', - querySerializer: defaultQuerySerializer, - ...override, -}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts deleted file mode 100644 index f8a73266f..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/auth.gen.ts +++ /dev/null @@ -1,42 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -export type AuthToken = string | undefined; - -export interface Auth { - /** - * Which part of the request do we use to send the auth? - * - * @default 'header' - */ - in?: 'header' | 'query' | 'cookie'; - /** - * Header or query parameter name. - * - * @default 'Authorization' - */ - name?: string; - scheme?: 'basic' | 'bearer'; - type: 'apiKey' | 'http'; -} - -export const getAuthToken = async ( - auth: Auth, - callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, -): Promise => { - const token = - typeof callback === 'function' ? await callback(auth) : callback; - - if (!token) { - return; - } - - if (auth.scheme === 'bearer') { - return `Bearer ${token}`; - } - - if (auth.scheme === 'basic') { - return `Basic ${btoa(token)}`; - } - - return token; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts deleted file mode 100644 index 49cd8925e..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/bodySerializer.gen.ts +++ /dev/null @@ -1,92 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { - ArrayStyle, - ObjectStyle, - SerializerOptions, -} from './pathSerializer.gen'; - -export type QuerySerializer = (query: Record) => string; - -export type BodySerializer = (body: any) => any; - -export interface QuerySerializerOptions { - allowReserved?: boolean; - array?: SerializerOptions; - object?: SerializerOptions; -} - -const serializeFormDataPair = ( - data: FormData, - key: string, - value: unknown, -): void => { - if (typeof value === 'string' || value instanceof Blob) { - data.append(key, value); - } else if (value instanceof Date) { - data.append(key, value.toISOString()); - } else { - data.append(key, JSON.stringify(value)); - } -}; - -const serializeUrlSearchParamsPair = ( - data: URLSearchParams, - key: string, - value: unknown, -): void => { - if (typeof value === 'string') { - data.append(key, value); - } else { - data.append(key, JSON.stringify(value)); - } -}; - -export const formDataBodySerializer = { - bodySerializer: | Array>>( - body: T, - ): FormData => { - const data = new FormData(); - - Object.entries(body).forEach(([key, value]) => { - if (value === undefined || value === null) { - return; - } - if (Array.isArray(value)) { - value.forEach((v) => serializeFormDataPair(data, key, v)); - } else { - serializeFormDataPair(data, key, value); - } - }); - - return data; - }, -}; - -export const jsonBodySerializer = { - bodySerializer: (body: T): string => - JSON.stringify(body, (_key, value) => - typeof value === 'bigint' ? value.toString() : value, - ), -}; - -export const urlSearchParamsBodySerializer = { - bodySerializer: | Array>>( - body: T, - ): string => { - const data = new URLSearchParams(); - - Object.entries(body).forEach(([key, value]) => { - if (value === undefined || value === null) { - return; - } - if (Array.isArray(value)) { - value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); - } else { - serializeUrlSearchParamsPair(data, key, value); - } - }); - - return data.toString(); - }, -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts deleted file mode 100644 index 71c88e852..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/params.gen.ts +++ /dev/null @@ -1,153 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -type Slot = 'body' | 'headers' | 'path' | 'query'; - -export type Field = - | { - in: Exclude; - /** - * Field name. This is the name we want the user to see and use. - */ - key: string; - /** - * 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; - } - | { - in: Extract; - /** - * Key isn't required for bodies. - */ - key?: string; - map?: string; - }; - -export interface Fields { - allowExtra?: Partial>; - args?: ReadonlyArray; -} - -export type FieldsConfig = ReadonlyArray; - -const extraPrefixesMap: Record = { - $body_: 'body', - $headers_: 'headers', - $path_: 'path', - $query_: 'query', -}; -const extraPrefixes = Object.entries(extraPrefixesMap); - -type KeyMap = Map< - string, - { - in: Slot; - map?: string; - } ->; - -const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { - if (!map) { - map = new Map(); - } - - for (const config of fields) { - if ('in' in config) { - if (config.key) { - map.set(config.key, { - in: config.in, - map: config.map, - }); - } - } else if (config.args) { - buildKeyMap(config.args, map); - } - } - - return map; -}; - -interface Params { - body: unknown; - headers: Record; - path: Record; - query: Record; -} - -const stripEmptySlots = (params: Params) => { - for (const [slot, value] of Object.entries(params)) { - if (value && typeof value === 'object' && !Object.keys(value).length) { - delete params[slot as Slot]; - } - } -}; - -export const buildClientParams = ( - args: ReadonlyArray, - fields: FieldsConfig, -) => { - const params: Params = { - body: {}, - headers: {}, - path: {}, - query: {}, - }; - - const map = buildKeyMap(fields); - - let config: FieldsConfig[number] | undefined; - - for (const [index, arg] of args.entries()) { - if (fields[index]) { - config = fields[index]; - } - - if (!config) { - continue; - } - - if ('in' in config) { - if (config.key) { - const field = map.get(config.key)!; - const name = field.map || config.key; - (params[field.in] as Record)[name] = arg; - } else { - params.body = arg; - } - } else { - for (const [key, value] of Object.entries(arg ?? {})) { - const field = map.get(key); - - if (field) { - const name = field.map || key; - (params[field.in] as Record)[name] = value; - } else { - const extra = extraPrefixes.find(([prefix]) => - key.startsWith(prefix), - ); - - if (extra) { - const [prefix, slot] = extra; - (params[slot] as Record)[ - key.slice(prefix.length) - ] = value; - } else { - for (const [slot, allowed] of Object.entries( - config.allowExtra ?? {}, - )) { - if (allowed) { - (params[slot as Slot] as Record)[key] = value; - break; - } - } - } - } - } - } - } - - stripEmptySlots(params); - - return params; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts deleted file mode 100644 index 8d9993104..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/pathSerializer.gen.ts +++ /dev/null @@ -1,181 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -interface SerializeOptions - extends SerializePrimitiveOptions, - SerializerOptions {} - -interface SerializePrimitiveOptions { - allowReserved?: boolean; - name: string; -} - -export interface SerializerOptions { - /** - * @default true - */ - explode: boolean; - style: T; -} - -export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; -export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; -type MatrixStyle = 'label' | 'matrix' | 'simple'; -export type ObjectStyle = 'form' | 'deepObject'; -type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; - -interface SerializePrimitiveParam extends SerializePrimitiveOptions { - value: string; -} - -export const separatorArrayExplode = (style: ArraySeparatorStyle) => { - switch (style) { - case 'label': - return '.'; - case 'matrix': - return ';'; - case 'simple': - return ','; - default: - return '&'; - } -}; - -export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { - switch (style) { - case 'form': - return ','; - case 'pipeDelimited': - return '|'; - case 'spaceDelimited': - return '%20'; - default: - return ','; - } -}; - -export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { - switch (style) { - case 'label': - return '.'; - case 'matrix': - return ';'; - case 'simple': - return ','; - default: - return '&'; - } -}; - -export const serializeArrayParam = ({ - allowReserved, - explode, - name, - style, - value, -}: SerializeOptions & { - value: unknown[]; -}) => { - if (!explode) { - const joinedValues = ( - allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) - ).join(separatorArrayNoExplode(style)); - switch (style) { - case 'label': - return `.${joinedValues}`; - case 'matrix': - return `;${name}=${joinedValues}`; - case 'simple': - return joinedValues; - default: - return `${name}=${joinedValues}`; - } - } - - const separator = separatorArrayExplode(style); - const joinedValues = value - .map((v) => { - if (style === 'label' || style === 'simple') { - return allowReserved ? v : encodeURIComponent(v as string); - } - - return serializePrimitiveParam({ - allowReserved, - name, - value: v as string, - }); - }) - .join(separator); - return style === 'label' || style === 'matrix' - ? separator + joinedValues - : joinedValues; -}; - -export const serializePrimitiveParam = ({ - allowReserved, - name, - value, -}: SerializePrimitiveParam) => { - if (value === undefined || value === null) { - return ''; - } - - if (typeof value === 'object') { - throw new Error( - 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', - ); - } - - return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; -}; - -export const serializeObjectParam = ({ - allowReserved, - explode, - name, - style, - value, - valueOnly, -}: SerializeOptions & { - value: Record | Date; - valueOnly?: boolean; -}) => { - if (value instanceof Date) { - return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; - } - - if (style !== 'deepObject' && !explode) { - let values: string[] = []; - Object.entries(value).forEach(([key, v]) => { - values = [ - ...values, - key, - allowReserved ? (v as string) : encodeURIComponent(v as string), - ]; - }); - const joinedValues = values.join(','); - switch (style) { - case 'form': - return `${name}=${joinedValues}`; - case 'label': - return `.${joinedValues}`; - case 'matrix': - return `;${name}=${joinedValues}`; - default: - return joinedValues; - } - } - - const separator = separatorObjectExplode(style); - const joinedValues = Object.entries(value) - .map(([key, v]) => - serializePrimitiveParam({ - allowReserved, - name: style === 'deepObject' ? `${name}[${key}]` : key, - value: v as string, - }), - ) - .join(separator); - return style === 'label' || style === 'matrix' - ? separator + joinedValues - : joinedValues; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts deleted file mode 100644 index f8fd78e28..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts +++ /dev/null @@ -1,264 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Config } from './types.gen'; - -export type ServerSentEventsOptions = Omit< - RequestInit, - 'method' -> & - Pick & { - /** - * Fetch API implementation. You can use this option to provide a custom - * fetch instance. - * - * @default globalThis.fetch - */ - fetch?: typeof fetch; - /** - * Implementing clients can call request interceptors inside this hook. - */ - onRequest?: (url: string, init: RequestInit) => Promise; - /** - * Callback invoked when a network or parsing error occurs during streaming. - * - * This option applies only if the endpoint returns a stream of events. - * - * @param error The error that occurred. - */ - onSseError?: (error: unknown) => void; - /** - * Callback invoked when an event is streamed from the server. - * - * This option applies only if the endpoint returns a stream of events. - * - * @param event Event streamed from the server. - * @returns Nothing (void). - */ - onSseEvent?: (event: StreamEvent) => void; - serializedBody?: RequestInit['body']; - /** - * Default retry delay in milliseconds. - * - * This option applies only if the endpoint returns a stream of events. - * - * @default 3000 - */ - sseDefaultRetryDelay?: number; - /** - * Maximum number of retry attempts before giving up. - */ - sseMaxRetryAttempts?: number; - /** - * Maximum retry delay in milliseconds. - * - * Applies only when exponential backoff is used. - * - * This option applies only if the endpoint returns a stream of events. - * - * @default 30000 - */ - sseMaxRetryDelay?: number; - /** - * Optional sleep function for retry backoff. - * - * Defaults to using `setTimeout`. - */ - sseSleepFn?: (ms: number) => Promise; - url: string; - }; - -export interface StreamEvent { - data: TData; - event?: string; - id?: string; - retry?: number; -} - -export type ServerSentEventsResult< - TData = unknown, - TReturn = void, - TNext = unknown, -> = { - stream: AsyncGenerator< - TData extends Record ? TData[keyof TData] : TData, - TReturn, - TNext - >; -}; - -export const createSseClient = ({ - onRequest, - onSseError, - onSseEvent, - responseTransformer, - responseValidator, - sseDefaultRetryDelay, - sseMaxRetryAttempts, - sseMaxRetryDelay, - sseSleepFn, - url, - ...options -}: ServerSentEventsOptions): ServerSentEventsResult => { - let lastEventId: string | undefined; - - const sleep = - sseSleepFn ?? - ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); - - const createStream = async function* () { - let retryDelay: number = sseDefaultRetryDelay ?? 3000; - let attempt = 0; - const signal = options.signal ?? new AbortController().signal; - - while (true) { - if (signal.aborted) break; - - attempt++; - - const headers = - options.headers instanceof Headers - ? options.headers - : new Headers(options.headers as Record | undefined); - - if (lastEventId !== undefined) { - headers.set('Last-Event-ID', lastEventId); - } - - try { - const requestInit: RequestInit = { - redirect: 'follow', - ...options, - body: options.serializedBody, - headers, - signal, - }; - let request = new Request(url, requestInit); - if (onRequest) { - request = await onRequest(url, requestInit); - } - // fetch must be assigned here, otherwise it would throw the error: - // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation - const _fetch = options.fetch ?? globalThis.fetch; - const response = await _fetch(request); - - if (!response.ok) - throw new Error( - `SSE failed: ${response.status} ${response.statusText}`, - ); - - if (!response.body) throw new Error('No body in SSE response'); - - const reader = response.body - .pipeThrough(new TextDecoderStream()) - .getReader(); - - let buffer = ''; - - const abortHandler = () => { - try { - reader.cancel(); - } catch { - // noop - } - }; - - signal.addEventListener('abort', abortHandler); - - try { - while (true) { - const { done, value } = await reader.read(); - if (done) break; - buffer += value; - - const chunks = buffer.split('\n\n'); - buffer = chunks.pop() ?? ''; - - for (const chunk of chunks) { - const lines = chunk.split('\n'); - const dataLines: Array = []; - let eventName: string | undefined; - - for (const line of lines) { - if (line.startsWith('data:')) { - dataLines.push(line.replace(/^data:\s*/, '')); - } else if (line.startsWith('event:')) { - eventName = line.replace(/^event:\s*/, ''); - } else if (line.startsWith('id:')) { - lastEventId = line.replace(/^id:\s*/, ''); - } else if (line.startsWith('retry:')) { - const parsed = Number.parseInt( - line.replace(/^retry:\s*/, ''), - 10, - ); - if (!Number.isNaN(parsed)) { - retryDelay = parsed; - } - } - } - - let data: unknown; - let parsedJson = false; - - if (dataLines.length) { - const rawData = dataLines.join('\n'); - try { - data = JSON.parse(rawData); - parsedJson = true; - } catch { - data = rawData; - } - } - - if (parsedJson) { - if (responseValidator) { - await responseValidator(data); - } - - if (responseTransformer) { - data = await responseTransformer(data); - } - } - - onSseEvent?.({ - data, - event: eventName, - id: lastEventId, - retry: retryDelay, - }); - - if (dataLines.length) { - yield data as any; - } - } - } - } finally { - signal.removeEventListener('abort', abortHandler); - reader.releaseLock(); - } - - break; // exit loop on normal completion - } catch (error) { - // connection failed or aborted; retry after delay - onSseError?.(error); - - if ( - sseMaxRetryAttempts !== undefined && - attempt >= sseMaxRetryAttempts - ) { - break; // stop after firing error - } - - // exponential backoff: double retry each attempt, cap at 30s - const backoff = Math.min( - retryDelay * 2 ** (attempt - 1), - sseMaxRetryDelay ?? 30000, - ); - await sleep(backoff); - } - } - }; - - const stream = createStream(); - - return { stream }; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts deleted file mode 100644 index 643c070c9..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/types.gen.ts +++ /dev/null @@ -1,118 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { Auth, AuthToken } from './auth.gen'; -import type { - BodySerializer, - QuerySerializer, - QuerySerializerOptions, -} from './bodySerializer.gen'; - -export type HttpMethod = - | 'connect' - | 'delete' - | 'get' - | 'head' - | 'options' - | 'patch' - | 'post' - | 'put' - | 'trace'; - -export type Client< - RequestFn = never, - Config = unknown, - MethodFn = never, - BuildUrlFn = never, - SseFn = never, -> = { - /** - * Returns the final request URL. - */ - buildUrl: BuildUrlFn; - getConfig: () => Config; - request: RequestFn; - setConfig: (config: Config) => Config; -} & { - [K in HttpMethod]: MethodFn; -} & ([SseFn] extends [never] - ? { sse?: never } - : { sse: { [K in HttpMethod]: SseFn } }); - -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; - /** - * A function for serializing request body parameter. By default, - * {@link JSON.stringify()} will be used. - */ - bodySerializer?: BodySerializer | null; - /** - * An object containing any HTTP headers that you want to pre-populate your - * `Headers` object with. - * - * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} - */ - headers?: - | RequestInit['headers'] - | Record< - string, - | string - | number - | boolean - | (string | number | boolean)[] - | null - | undefined - | unknown - >; - /** - * The request method. - * - * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} - */ - method?: Uppercase; - /** - * A function for serializing request query parameters. By default, arrays - * will be exploded in form style, objects will be exploded in deepObject - * style, and reserved characters are percent-encoded. - * - * This method will have no effect if the native `paramsSerializer()` Axios - * API function is used. - * - * {@link https://swagger.io/docs/specification/serialization/#query View examples} - */ - querySerializer?: QuerySerializer | QuerySerializerOptions; - /** - * 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; - /** - * 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; - /** - * 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; -} - -type IsExactlyNeverOrNeverUndefined = [T] extends [never] - ? true - : [T] extends [never | undefined] - ? [undefined] extends [T] - ? false - : true - : false; - -export type OmitNever> = { - [K in keyof T as IsExactlyNeverOrNeverUndefined extends true - ? never - : K]: T[K]; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts deleted file mode 100644 index ac31396fe..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/utils.gen.ts +++ /dev/null @@ -1,114 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import type { QuerySerializer } from './bodySerializer.gen'; -import { - type ArraySeparatorStyle, - serializeArrayParam, - serializeObjectParam, - serializePrimitiveParam, -} from './pathSerializer.gen'; - -export interface PathSerializer { - path: Record; - url: string; -} - -export const PATH_PARAM_RE = /\{[^{}]+\}/g; - -export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { - let url = _url; - const matches = _url.match(PATH_PARAM_RE); - if (matches) { - for (const match of matches) { - let explode = false; - let name = match.substring(1, match.length - 1); - let style: ArraySeparatorStyle = 'simple'; - - if (name.endsWith('*')) { - explode = true; - name = name.substring(0, name.length - 1); - } - - if (name.startsWith('.')) { - name = name.substring(1); - style = 'label'; - } else if (name.startsWith(';')) { - name = name.substring(1); - style = 'matrix'; - } - - const value = path[name]; - - if (value === undefined || value === null) { - continue; - } - - if (Array.isArray(value)) { - url = url.replace( - match, - serializeArrayParam({ explode, name, style, value }), - ); - continue; - } - - if (typeof value === 'object') { - url = url.replace( - match, - serializeObjectParam({ - explode, - name, - style, - value: value as Record, - valueOnly: true, - }), - ); - continue; - } - - if (style === 'matrix') { - url = url.replace( - match, - `;${serializePrimitiveParam({ - name, - value: value as string, - })}`, - ); - continue; - } - - const replaceValue = encodeURIComponent( - style === 'label' ? `.${value as string}` : (value as string), - ); - url = url.replace(match, replaceValue); - } - } - return url; -}; - -export const getUrl = ({ - baseUrl, - path, - query, - querySerializer, - url: _url, -}: { - baseUrl?: string; - path?: Record; - query?: Record; - querySerializer: QuerySerializer; - url: string; -}) => { - const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; - let url = (baseUrl ?? '') + pathUrl; - if (path) { - url = defaultPathSerializer({ path, url }); - } - let search = query ? querySerializer(query) : ''; - if (search.startsWith('?')) { - search = search.substring(1); - } - if (search) { - url += `?${search}`; - } - return url; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/index.ts deleted file mode 100644 index e64537d21..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts deleted file mode 100644 index e79f50b13..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/sdk.gen.ts +++ /dev/null @@ -1,409 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; - -export type Options = ClientOptions & { - /** - * You can provide a client instance returned by `createClient()` instead of - * individual options. This might be also useful if you want to implement a - * custom client. - */ - client?: Client; - /** - * You can pass arbitrary values through the `meta` object. This can be - * used to access values that aren't defined as part of the SDK function. - */ - meta?: Record; -}; - -export const export_ = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/no+tag', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const fooWow = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/no+tag', - ...options - }); -}; - -export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/simple/$count', - ...options - }); -}; - -export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/simple:operation', - ...options - }); -}; - -export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/simple', - ...options - }); -}; - -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', - ...options - }); -}; - -export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/descriptions', - ...options - }); -}; - -/** - * @deprecated - */ -export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/deprecated', - ...options - }); -}; - -export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/{parameterPath}', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const getCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/parameters', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/parameters', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options.headers - } - }); -}; - -export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/requestBody', - ...options, - headers: { - 'Content-Type': 'application/json', - ...options?.headers - } - }); -}; - -export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - ...formDataBodySerializer, - url: '/api/v{api-version}/formData', - ...options, - headers: { - 'Content-Type': null, - ...options?.headers - } - }); -}; - -export const callWithDefaultParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/defaults', - ...options - }); -}; - -export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/duplicate', - ...options - }); -}; - -export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/no-content', - ...options - }); -}; - -export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/response-and-no-content', - ...options - }); -}; - -export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/a', - ...options - }); -}; - -export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multiple-tags/b', - ...options - }); -}; - -export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/response', - ...options - }); -}; - -export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/collectionFormat', - ...options - }); -}; - -export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/types', - ...options - }); -}; - -export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - ...urlSearchParamsBodySerializer, - url: '/api/v{api-version}/upload', - ...options, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - ...options.headers - } - }); -}; - -export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/file/{id}', - ...options - }); -}; - -export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/complex', - ...options - }); -}; - -export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ - url: '/api/v{api-version}/multipart', - ...options - }); -}; - -export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - ...formDataBodySerializer, - url: '/api/v{api-version}/multipart', - ...options, - headers: { - 'Content-Type': null, - ...options?.headers - } - }); -}; - -export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ - url: '/api/v{api-version}/complex/{id}', - ...options, - headers: { - 'Content-Type': 'application/json-patch+json', - ...options.headers - } - }); -}; - -export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/header', - ...options - }); -}; - -export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/error', - ...options - }); -}; - -export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', - ...options - }); -}; - -/** - * Login User - */ -export const putWithFormUrlEncoded = (options: Options) => { - return (options.client ?? _heyApiClient).put({ - ...urlSearchParamsBodySerializer, - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', - ...options, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - ...options.headers - } - }); -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/types.gen.ts deleted file mode 100644 index a6ae7c816..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/types.gen.ts +++ /dev/null @@ -1,2063 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -/** - * Model with number-only name - */ -export type _400 = string; - -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; - -/** - * External ref to shared model (B) - */ -export type ExternalRefB = ExternalRefA; - -/** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ -export type CamelCaseCommentWithBreaks = number; - -/** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ -export type CommentWithBreaks = number; - -/** - * Testing backticks in string: `backticks` and ```multiple backticks``` should work - */ -export type CommentWithBackticks = number; - -/** - * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work - */ -export type CommentWithBackticksAndQuotes = number; - -/** - * Testing slashes in string: \backwards\\\ and /forwards/// should work - */ -export type CommentWithSlashes = number; - -/** - * Testing expression placeholders in string: ${expression} should work - */ -export type CommentWithExpressionPlaceholders = number; - -/** - * Testing quotes in string: 'single quote''' and "double quotes""" should work - */ -export type CommentWithQuotes = number; - -/** - * Testing reserved characters in string: * inline * and ** inline ** should work - */ -export type CommentWithReservedCharacters = number; - -/** - * This is a simple number - */ -export type SimpleInteger = number; - -/** - * This is a simple boolean - */ -export type SimpleBoolean = boolean; - -/** - * This is a simple string - */ -export type SimpleString = string; - -/** - * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) - */ -export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; - -/** - * This is a simple file - */ -export type SimpleFile = Blob | File; - -/** - * This is a simple reference - */ -export type SimpleReference = ModelWithString; - -/** - * This is a simple string - */ -export type SimpleStringWithPattern = string | null; - -/** - * This is a simple enum with strings - */ -export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; - -export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; - -/** - * This is a simple enum with numbers - */ -export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; - -/** - * Success=1,Warning=2,Error=3 - */ -export type EnumFromDescription = number; - -/** - * This is a simple enum with numbers - */ -export type EnumWithExtensions = 200 | 400 | 500; - -export type EnumWithXEnumNames = 0 | 1 | 2; - -/** - * This is a simple array with numbers - */ -export type ArrayWithNumbers = Array; - -/** - * This is a simple array with booleans - */ -export type ArrayWithBooleans = Array; - -/** - * This is a simple array with strings - */ -export type ArrayWithStrings = Array; - -/** - * This is a simple array with references - */ -export type ArrayWithReferences = Array; - -/** - * This is a simple array containing an array - */ -export type ArrayWithArray = Array>; - -/** - * This is a simple array with properties - */ -export type ArrayWithProperties = Array<{ - '16x16'?: CamelCaseCommentWithBreaks; - bar?: string; -}>; - -/** - * This is a simple array with any of properties - */ -export type ArrayWithAnyOfProperties = Array<{ - foo?: string; -} | { - bar?: string; -}>; - -export type AnyOfAnyAndNull = { - data?: unknown | null; -}; - -/** - * This is a simple array with any of properties - */ -export type AnyOfArrays = { - results?: Array<{ - foo?: string; - } | { - bar?: string; - }>; -}; - -/** - * This is a string dictionary - */ -export type DictionaryWithString = { - [key: string]: string; -}; - -export type DictionaryWithPropertiesAndAdditionalProperties = { - foo?: number; - bar?: boolean; - [key: string]: string | number | boolean | undefined; -}; - -/** - * This is a string reference - */ -export type DictionaryWithReference = { - [key: string]: ModelWithString; -}; - -/** - * This is a complex dictionary - */ -export type DictionaryWithArray = { - [key: string]: Array; -}; - -/** - * This is a string dictionary - */ -export type DictionaryWithDictionary = { - [key: string]: { - [key: string]: string; - }; -}; - -/** - * This is a complex dictionary - */ -export type DictionaryWithProperties = { - [key: string]: { - foo?: string; - bar?: string; - }; -}; - -/** - * This is a model with one number property - */ -export type ModelWithInteger = { - /** - * This is a simple number property - */ - prop?: number; -}; - -/** - * This is a model with one boolean property - */ -export type ModelWithBoolean = { - /** - * This is a simple boolean property - */ - prop?: boolean; -}; - -/** - * This is a model with one string property - */ -export type ModelWithString = { - /** - * This is a simple string property - */ - prop?: string; -}; - -/** - * This is a model with one string property - */ -export type ModelWithStringError = { - /** - * This is a simple string property - */ - prop?: string; -}; - -/** - * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) - */ -export type ModelFromZendesk = string; - -/** - * This is a model with one string property - */ -export type ModelWithNullableString = { - /** - * This is a simple string property - */ - nullableProp1?: string | null; - /** - * This is a simple string property - */ - nullableRequiredProp1: string | null; - /** - * This is a simple string property - */ - nullableProp2?: string | null; - /** - * This is a simple string property - */ - nullableRequiredProp2: string | null; - /** - * This is a simple enum with strings - */ - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; -}; - -/** - * This is a model with one enum - */ -export type ModelWithEnum = { - /** - * This is a simple enum with strings - */ - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; - /** - * These are the HTTP error code enums - */ - statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; - /** - * Simple boolean enum - */ - bool?: true; -}; - -/** - * This is a model with one enum with escaped name - */ -export type ModelWithEnumWithHyphen = { - /** - * Foo-Bar-Baz-Qux - */ - 'foo-bar-baz-qux'?: '3.0'; -}; - -/** - * This is a model with one enum - */ -export type ModelWithEnumFromDescription = { - /** - * Success=1,Warning=2,Error=3 - */ - test?: number; -}; - -/** - * This is a model with nested enums - */ -export type ModelWithNestedEnums = { - dictionaryWithEnum?: { - [key: string]: 'Success' | 'Warning' | 'Error'; - }; - dictionaryWithEnumFromDescription?: { - [key: string]: number; - }; - arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; - arrayWithDescription?: Array; - /** - * This is a simple enum with strings - */ - 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; -}; - -/** - * This is a model with one property containing a reference - */ -export type ModelWithReference = { - prop?: ModelWithProperties; -}; - -/** - * This is a model with one property containing an array - */ -export type ModelWithArrayReadOnlyAndWriteOnly = { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -}; - -/** - * This is a model with one property containing an array - */ -export type ModelWithArray = { - prop?: Array; - propWithFile?: Array; - propWithNumber?: Array; -}; - -/** - * This is a model with one property containing a dictionary - */ -export type ModelWithDictionary = { - prop?: { - [key: string]: string; - }; -}; - -/** - * This is a deprecated model with a deprecated property - * @deprecated - */ -export type DeprecatedModel = { - /** - * This is a deprecated property - * @deprecated - */ - prop?: string; -}; - -/** - * This is a model with one property containing a circular reference - */ -export type ModelWithCircularReference = { - prop?: ModelWithCircularReference; -}; - -/** - * This is a model with one property with a 'one of' relationship - */ -export type CompositionWithOneOf = { - propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; -}; - -/** - * This is a model with one property with a 'one of' relationship where the options are not $ref - */ -export type CompositionWithOneOfAnonymous = { - propA?: { - propA?: string; - } | string | number; -}; - -/** - * Circle - */ -export type ModelCircle = { - kind: string; - radius?: number; -}; - -/** - * Square - */ -export type ModelSquare = { - kind: string; - sideLength?: number; -}; - -/** - * This is a model with one property with a 'one of' relationship where the options are not $ref - */ -export type CompositionWithOneOfDiscriminator = ({ - kind: 'circle'; -} & ModelCircle) | ({ - kind: 'square'; -} & ModelSquare); - -/** - * This is a model with one property with a 'any of' relationship - */ -export type CompositionWithAnyOf = { - propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; -}; - -/** - * This is a model with one property with a 'any of' relationship where the options are not $ref - */ -export type CompositionWithAnyOfAnonymous = { - propA?: { - propA?: string; - } | string | number; -}; - -/** - * This is a model with nested 'any of' property with a type null - */ -export type CompositionWithNestedAnyAndTypeNull = { - propA?: Array | Array; -}; - -export type _3eNum1Период = 'Bird' | 'Dog'; - -export type ConstValue = 'ConstValue'; - -/** - * This is a model with one property with a 'any of' relationship where the options are not $ref - */ -export type CompositionWithNestedAnyOfAndNull = { - /** - * Scopes - */ - propA?: Array<_3eNum1Период | ConstValue> | null; -}; - -/** - * This is a model with one property with a 'one of' relationship - */ -export type CompositionWithOneOfAndNullable = { - propA?: { - boolean?: boolean; - } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; -}; - -/** - * This is a model that contains a simple dictionary within composition - */ -export type CompositionWithOneOfAndSimpleDictionary = { - propA?: boolean | { - [key: string]: number; - }; -}; - -/** - * This is a model that contains a dictionary of simple arrays within composition - */ -export type CompositionWithOneOfAndSimpleArrayDictionary = { - propA?: boolean | { - [key: string]: Array; - }; -}; - -/** - * This is a model that contains a dictionary of complex arrays (composited) within composition - */ -export type CompositionWithOneOfAndComplexArrayDictionary = { - propA?: boolean | { - [key: string]: Array; - }; -}; - -/** - * This is a model with one property with a 'all of' relationship - */ -export type CompositionWithAllOfAndNullable = { - propA?: ({ - boolean?: boolean; - } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; -}; - -/** - * This is a model with one property with a 'any of' relationship - */ -export type CompositionWithAnyOfAndNullable = { - propA?: { - boolean?: boolean; - } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; -}; - -/** - * This is a base model with two simple optional properties - */ -export type CompositionBaseModel = { - firstName?: string; - lastname?: string; -}; - -/** - * This is a model that extends the base model - */ -export type CompositionExtendedModel = CompositionBaseModel & { - age: number; - firstName: string; - lastname: string; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithProperties = { - required: string; - readonly requiredAndReadOnly: string; - requiredAndNullable: string | null; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithNestedProperties = { - readonly first: { - readonly second: { - readonly third: string | null; - } | null; - } | null; -}; - -/** - * This is a model with duplicated properties - */ -export type ModelWithDuplicateProperties = { - prop?: ModelWithString; -}; - -/** - * This is a model with ordered properties - */ -export type ModelWithOrderedProperties = { - zebra?: string; - apple?: string; - hawaii?: string; -}; - -/** - * This is a model with duplicated imports - */ -export type ModelWithDuplicateImports = { - propA?: ModelWithString; - propB?: ModelWithString; - propC?: ModelWithString; -}; - -/** - * This is a model that extends another model - */ -export type ModelThatExtends = ModelWithString & { - propExtendsA?: string; - propExtendsB?: ModelWithString; -}; - -/** - * This is a model that extends another model - */ -export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { - propExtendsC?: string; - propExtendsD?: ModelWithString; -}; - -/** - * This is a model that contains a some patterns - */ -export type ModelWithPattern = { - key: string; - name: string; - readonly enabled?: boolean; - readonly modified?: string; - id?: string; - text?: string; - patternWithSingleQuotes?: string; - patternWithNewline?: string; - patternWithBacktick?: string; -}; - -export type File = { - /** - * Id - */ - readonly id?: string; - /** - * Updated at - */ - readonly updated_at?: string; - /** - * Created at - */ - readonly created_at?: string; - /** - * Mime - */ - mime: string; - /** - * File - */ - readonly file?: string; -}; - -export type Default = { - name?: string; -}; - -export type Pageable = { - page?: number; - size?: number; - sort?: Array; -}; - -/** - * This is a free-form object without additionalProperties. - */ -export type FreeFormObjectWithoutAdditionalProperties = { - [key: string]: unknown; -}; - -/** - * This is a free-form object with additionalProperties: true. - */ -export type FreeFormObjectWithAdditionalPropertiesEqTrue = { - [key: string]: unknown; -}; - -/** - * This is a free-form object with additionalProperties: {}. - */ -export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { - [key: string]: unknown; -}; - -export type ModelWithConst = { - String?: 'String'; - number?: 0; - null?: null; - withType?: 'Some string'; -}; - -/** - * This is a model with one property and additionalProperties: true - */ -export type ModelWithAdditionalPropertiesEqTrue = { - /** - * This is a simple string property - */ - prop?: string; - [key: string]: unknown | string | undefined; -}; - -export type NestedAnyOfArraysNullable = { - nullableArray?: Array | null; -}; - -export type CompositionWithOneOfAndProperties = ({ - foo: SimpleParameter; -} | { - bar: NonAsciiStringæøåÆøÅöôêÊ字符串; -}) & { - baz: number | null; - qux: number; -}; - -/** - * An object that can be null - */ -export type NullableObject = { - foo?: string; -} | null; - -/** - * Some % character - */ -export type CharactersInDescription = string; - -export type ModelWithNullableObject = { - data?: NullableObject; -}; - -export type ModelWithOneOfEnum = { - foo: 'Bar'; -} | { - foo: 'Baz'; -} | { - foo: 'Qux'; -} | { - content: string; - foo: 'Quux'; -} | { - content: [ - string, - string - ]; - foo: 'Corge'; -}; - -export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; - -export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; - -export type ModelWithNestedArrayEnumsData = { - foo?: Array; - bar?: Array; -}; - -export type ModelWithNestedArrayEnums = { - array_strings?: Array; - data?: ModelWithNestedArrayEnumsData; -}; - -export type ModelWithNestedCompositionEnums = { - foo?: ModelWithNestedArrayEnumsDataFoo; -}; - -export type ModelWithReadOnlyAndWriteOnly = { - foo: string; - readonly bar: string; -}; - -export type ModelWithConstantSizeArray = [ - number, - number -]; - -export type ModelWithAnyOfConstantSizeArray = [ - number | string, - number | string, - number | string -]; - -export type ModelWithPrefixItemsConstantSizeArray = [ - ModelWithInteger, - number | string, - string -]; - -export type ModelWithAnyOfConstantSizeArrayNullable = [ - number | null | string, - number | null | string, - number | null | string -]; - -export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ - number | Import, - number | Import -]; - -export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ - number & string, - number & string -]; - -export type ModelWithNumericEnumUnion = { - /** - * Период - */ - value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; -}; - -/** - * Some description with `back ticks` - */ -export type ModelWithBackticksInDescription = { - /** - * The template `that` should be used for parsing and importing the contents of the CSV file. - * - *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

- *
-     * [
-     * {
-     * "resourceType": "Asset",
-     * "identifier": {
-     * "name": "${1}",
-     * "domain": {
-     * "name": "${2}",
-     * "community": {
-     * "name": "Some Community"
-     * }
-     * }
-     * },
-     * "attributes" : {
-     * "00000000-0000-0000-0000-000000003115" : [ {
-     * "value" : "${3}"
-     * } ],
-     * "00000000-0000-0000-0000-000000000222" : [ {
-     * "value" : "${4}"
-     * } ]
-     * }
-     * }
-     * ]
-     * 
- */ - template?: string; -}; - -export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { - baz: number | null; - qux: number; -}; - -/** - * Model used to test deduplication strategy (unused) - */ -export type ParameterSimpleParameterUnused = string; - -/** - * Model used to test deduplication strategy - */ -export type PostServiceWithEmptyTagResponse = string; - -/** - * Model used to test deduplication strategy - */ -export type PostServiceWithEmptyTagResponse2 = string; - -/** - * Model used to test deduplication strategy - */ -export type DeleteFooData = string; - -/** - * Model used to test deduplication strategy - */ -export type DeleteFooData2 = string; - -/** - * Model with restricted keyword name - */ -export type Import = string; - -export type SchemaWithFormRestrictedKeys = { - description?: string; - 'x-enum-descriptions'?: string; - 'x-enum-varnames'?: string; - 'x-enumNames'?: string; - title?: string; - object?: { - description?: string; - 'x-enum-descriptions'?: string; - 'x-enum-varnames'?: string; - 'x-enumNames'?: string; - title?: string; - }; - array?: Array<{ - description?: string; - 'x-enum-descriptions'?: string; - 'x-enum-varnames'?: string; - 'x-enumNames'?: string; - title?: string; - }>; -}; - -/** - * This schema was giving PascalCase transformations a hard time - */ -export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { - /** - * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. - */ - preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; -}; - -/** - * This schema was giving PascalCase transformations a hard time - */ -export type IoK8sApimachineryPkgApisMetaV1Preconditions = { - /** - * Specifies the target ResourceVersion - */ - resourceVersion?: string; - /** - * Specifies the target UID. - */ - uid?: string; -}; - -export type AdditionalPropertiesUnknownIssue = { - [key: string]: string | number; -}; - -export type AdditionalPropertiesUnknownIssue2 = { - [key: string]: string | number; -}; - -export type AdditionalPropertiesUnknownIssue3 = string & { - entries: { - [key: string]: AdditionalPropertiesUnknownIssue; - }; -}; - -export type AdditionalPropertiesIntegerIssue = { - value: number; - [key: string]: number; -}; - -export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; - -export type GenericSchemaDuplicateIssue1SystemBoolean = { - item?: boolean; - error?: string | null; - readonly hasError?: boolean; - data?: { - [key: string]: never; - }; -}; - -export type GenericSchemaDuplicateIssue1SystemString = { - item?: string | null; - error?: string | null; - readonly hasError?: boolean; -}; - -/** - * This is a model with one nested property - */ -export type ModelWithPropertiesWritable = { - required: string; - requiredAndNullable: string | null; - string?: string; - number?: number; - boolean?: boolean; - reference?: ModelWithString; - 'property with space'?: string; - default?: string; - try?: string; -}; - -/** - * This is a model that contains a some patterns - */ -export type ModelWithPatternWritable = { - key: string; - name: string; - id?: string; - text?: string; - patternWithSingleQuotes?: string; - patternWithNewline?: string; - patternWithBacktick?: string; -}; - -export type FileWritable = { - /** - * Mime - */ - mime: string; -}; - -export type ModelWithReadOnlyAndWriteOnlyWritable = { - foo: string; - baz: string; -}; - -export type AdditionalPropertiesUnknownIssueWritable = { - [key: string]: string | number; -}; - -export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { - item?: boolean; - error?: string | null; - data?: { - [key: string]: never; - }; -}; - -export type GenericSchemaDuplicateIssue1SystemStringWritable = { - item?: string | null; - error?: string | null; -}; - -/** - * This is a reusable parameter - */ -export type SimpleParameter = string; - -/** - * Parameter with illegal characters - */ -export type XFooBar = ModelWithString; - -/** - * A reusable request body - */ -export type SimpleRequestBody = ModelWithString; - -/** - * A reusable request body - */ -export type SimpleFormData = ModelWithString; - -export type ExportData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type PatchApiVbyApiVersionNoTagData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type PatchApiVbyApiVersionNoTagResponses = { - /** - * OK - */ - default: unknown; -}; - -export type ImportData = { - body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type ImportResponses = { - /** - * Success - */ - 200: ModelFromZendesk; - /** - * Default success response - */ - default: ModelWithReadOnlyAndWriteOnly; -}; - -export type ImportResponse = ImportResponses[keyof ImportResponses]; - -export type FooWowData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no+tag'; -}; - -export type FooWowResponses = { - /** - * OK - */ - default: unknown; -}; - -export type ApiVVersionODataControllerCountData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple/$count'; -}; - -export type ApiVVersionODataControllerCountResponses = { - /** - * Success - */ - 200: ModelFromZendesk; -}; - -export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; - -export type GetApiVbyApiVersionSimpleOperationData = { - body?: never; - path: { - /** - * foo in method - */ - foo_param: string; - }; - query?: never; - url: '/api/v{api-version}/simple:operation'; -}; - -export type GetApiVbyApiVersionSimpleOperationErrors = { - /** - * Default error response - */ - default: ModelWithBoolean; -}; - -export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; - -export type GetApiVbyApiVersionSimpleOperationResponses = { - /** - * Response is a simple number - */ - 200: number; -}; - -export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; - -export type DeleteCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type GetCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type HeadCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type OptionsCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PatchCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PostCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type PutCallWithoutParametersAndResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/simple'; -}; - -export type DeleteFooData3 = { - body?: never; - headers: { - /** - * Parameter with illegal characters - */ - 'x-Foo-Bar': ModelWithString; - }; - path: { - /** - * foo in method - */ - foo_param: string; - /** - * bar in method - */ - BarParam: string; - }; - query?: never; - url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; -}; - -export type CallWithDescriptionsData = { - body?: never; - path?: never; - query?: { - /** - * Testing multiline comments in string: First line - * Second line - * - * Fourth line - */ - parameterWithBreaks?: string; - /** - * Testing backticks in string: `backticks` and ```multiple backticks``` should work - */ - parameterWithBackticks?: string; - /** - * Testing slashes in string: \backwards\\\ and /forwards/// should work - */ - parameterWithSlashes?: string; - /** - * Testing expression placeholders in string: ${expression} should work - */ - parameterWithExpressionPlaceholders?: string; - /** - * Testing quotes in string: 'single quote''' and "double quotes""" should work - */ - parameterWithQuotes?: string; - /** - * Testing reserved characters in string: * inline * and ** inline ** should work - */ - parameterWithReservedCharacters?: string; - }; - url: '/api/v{api-version}/descriptions'; -}; - -export type DeprecatedCallData = { - body?: never; - headers: { - /** - * This parameter is deprecated - * @deprecated - */ - parameter: DeprecatedModel | null; - }; - path?: never; - query?: never; - url: '/api/v{api-version}/parameters/deprecated'; -}; - -export type CallWithParametersData = { - /** - * This is the parameter that goes into the body - */ - body: { - [key: string]: unknown; - } | null; - headers: { - /** - * This is the parameter that goes into the header - */ - parameterHeader: string | null; - }; - path: { - /** - * This is the parameter that goes into the path - */ - parameterPath: string | null; - /** - * api-version should be required in standalone clients - */ - 'api-version': string | null; - }; - query: { - foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; - foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; - /** - * This is the parameter that goes into the query params - */ - cursor: string | null; - }; - url: '/api/v{api-version}/parameters/{parameterPath}'; -}; - -export type CallWithWeirdParameterNamesData = { - /** - * This is the parameter that goes into the body - */ - body: ModelWithString | null; - headers: { - /** - * This is the parameter that goes into the request header - */ - 'parameter.header': string | null; - }; - path: { - /** - * This is the parameter that goes into the path - */ - 'parameter.path.1'?: string; - /** - * This is the parameter that goes into the path - */ - 'parameter-path-2'?: string; - /** - * This is the parameter that goes into the path - */ - 'PARAMETER-PATH-3'?: string; - /** - * api-version should be required in standalone clients - */ - 'api-version': string | null; - }; - query: { - /** - * This is the parameter with a reserved keyword - */ - default?: string; - /** - * This is the parameter that goes into the request query params - */ - 'parameter-query': string | null; - }; - url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; -}; - -export type GetCallWithOptionalParamData = { - /** - * This is a required parameter - */ - body: ModelWithOneOfEnum; - path?: never; - query?: { - /** - * This is an optional parameter - */ - page?: number; - }; - url: '/api/v{api-version}/parameters'; -}; - -export type PostCallWithOptionalParamData = { - /** - * This is an optional parameter - */ - body?: { - offset?: number | null; - }; - path?: never; - query: { - /** - * This is a required parameter - */ - parameter: Pageable; - }; - url: '/api/v{api-version}/parameters'; -}; - -export type PostCallWithOptionalParamResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Success - */ - 204: void; -}; - -export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; - -export type PostApiVbyApiVersionRequestBodyData = { - /** - * A reusable request body - */ - body?: SimpleRequestBody; - path?: never; - query?: { - /** - * This is a reusable parameter - */ - parameter?: string; - }; - url: '/api/v{api-version}/requestBody'; -}; - -export type PostApiVbyApiVersionFormDataData = { - /** - * A reusable request body - */ - body?: SimpleFormData; - path?: never; - query?: { - /** - * This is a reusable parameter - */ - parameter?: string; - }; - url: '/api/v{api-version}/formData'; -}; - -export type CallWithDefaultParametersData = { - body?: never; - path?: never; - query?: { - /** - * This is a simple string with default value - */ - parameterString?: string | null; - /** - * This is a simple number with default value - */ - parameterNumber?: number | null; - /** - * This is a simple boolean with default value - */ - parameterBoolean?: boolean | null; - /** - * This is a simple enum with default value - */ - parameterEnum?: 'Success' | 'Warning' | 'Error'; - /** - * This is a simple model with default value - */ - parameterModel?: ModelWithString | null; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type CallWithDefaultOptionalParametersData = { - body?: never; - path?: never; - query?: { - /** - * This is a simple string that is optional with default value - */ - parameterString?: string; - /** - * This is a simple number that is optional with default value - */ - parameterNumber?: number; - /** - * This is a simple boolean that is optional with default value - */ - parameterBoolean?: boolean; - /** - * This is a simple enum that is optional with default value - */ - parameterEnum?: 'Success' | 'Warning' | 'Error'; - /** - * This is a simple model that is optional with default value - */ - parameterModel?: ModelWithString; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type CallToTestOrderOfParamsData = { - body?: never; - path?: never; - query: { - /** - * This is a optional string with default - */ - parameterOptionalStringWithDefault?: string; - /** - * This is a optional string with empty default - */ - parameterOptionalStringWithEmptyDefault?: string; - /** - * This is a optional string with no default - */ - parameterOptionalStringWithNoDefault?: string; - /** - * This is a string with default - */ - parameterStringWithDefault: string; - /** - * This is a string with empty default - */ - parameterStringWithEmptyDefault: string; - /** - * This is a string with no default - */ - parameterStringWithNoDefault: string; - /** - * This is a string that can be null with no default - */ - parameterStringNullableWithNoDefault?: string | null; - /** - * This is a string that can be null with default - */ - parameterStringNullableWithDefault?: string | null; - }; - url: '/api/v{api-version}/defaults'; -}; - -export type DuplicateNameData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName2Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName3Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type DuplicateName4Data = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/duplicate'; -}; - -export type CallWithNoContentResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/no-content'; -}; - -export type CallWithNoContentResponseResponses = { - /** - * Success - */ - 204: void; -}; - -export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; - -export type CallWithResponseAndNoContentResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/response-and-no-content'; -}; - -export type CallWithResponseAndNoContentResponseResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Success - */ - 204: void; -}; - -export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; - -export type DummyAData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/a'; -}; - -export type DummyAResponses = { - 200: _400; -}; - -export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; - -export type DummyBData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multiple-tags/b'; -}; - -export type DummyBResponses = { - /** - * Success - */ - 204: void; -}; - -export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; - -export type CallWithResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithResponseResponses = { - default: Import; -}; - -export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; - -export type CallWithDuplicateResponsesData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithDuplicateResponsesErrors = { - /** - * Message for 500 error - */ - 500: ModelWithStringError; - /** - * Message for 501 error - */ - 501: ModelWithStringError; - /** - * Message for 502 error - */ - 502: ModelWithStringError; - /** - * Message for 4XX errors - */ - '4XX': DictionaryWithArray; - /** - * Default error response - */ - default: ModelWithBoolean; -}; - -export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; - -export type CallWithDuplicateResponsesResponses = { - /** - * Message for 200 response - */ - 200: ModelWithBoolean & ModelWithInteger; - /** - * Message for 201 response - */ - 201: ModelWithString; - /** - * Message for 202 response - */ - 202: ModelWithString; -}; - -export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; - -export type CallWithResponsesData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/response'; -}; - -export type CallWithResponsesErrors = { - /** - * Message for 500 error - */ - 500: ModelWithStringError; - /** - * Message for 501 error - */ - 501: ModelWithStringError; - /** - * Message for 502 error - */ - 502: ModelWithStringError; - /** - * Message for default response - */ - default: ModelWithStringError; -}; - -export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; - -export type CallWithResponsesResponses = { - /** - * Message for 200 response - */ - 200: { - readonly '@namespace.string'?: string; - readonly '@namespace.integer'?: number; - readonly value?: Array; - }; - /** - * Message for 201 response - */ - 201: ModelThatExtends; - /** - * Message for 202 response - */ - 202: ModelThatExtendsExtends; -}; - -export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; - -export type CollectionFormatData = { - body?: never; - path?: never; - query: { - /** - * This is an array parameter that is sent as csv format (comma-separated values) - */ - parameterArrayCSV: Array | null; - /** - * This is an array parameter that is sent as ssv format (space-separated values) - */ - parameterArraySSV: Array | null; - /** - * This is an array parameter that is sent as tsv format (tab-separated values) - */ - parameterArrayTSV: Array | null; - /** - * This is an array parameter that is sent as pipes format (pipe-separated values) - */ - parameterArrayPipes: Array | null; - /** - * This is an array parameter that is sent as multi format (multiple parameter instances) - */ - parameterArrayMulti: Array | null; - }; - url: '/api/v{api-version}/collectionFormat'; -}; - -export type TypesData = { - body?: never; - path?: { - /** - * This is a number parameter - */ - id?: number; - }; - query: { - /** - * This is a number parameter - */ - parameterNumber: number; - /** - * This is a string parameter - */ - parameterString: string | null; - /** - * This is a boolean parameter - */ - parameterBoolean: boolean | null; - /** - * This is an object parameter - */ - parameterObject: { - [key: string]: unknown; - } | null; - /** - * This is an array parameter - */ - parameterArray: Array | null; - /** - * This is a dictionary parameter - */ - parameterDictionary: { - [key: string]: unknown; - } | null; - /** - * This is an enum parameter - */ - parameterEnum: 'Success' | 'Warning' | 'Error' | null; - }; - url: '/api/v{api-version}/types'; -}; - -export type TypesResponses = { - /** - * Response is a simple number - */ - 200: number; - /** - * Response is a simple string - */ - 201: string; - /** - * Response is a simple boolean - */ - 202: boolean; - /** - * Response is a simple object - */ - 203: { - [key: string]: unknown; - }; -}; - -export type TypesResponse = TypesResponses[keyof TypesResponses]; - -export type UploadFileData = { - body: Blob | File; - path: { - /** - * api-version should be required in standalone clients - */ - 'api-version': string | null; - }; - query?: never; - url: '/api/v{api-version}/upload'; -}; - -export type UploadFileResponses = { - 200: boolean; -}; - -export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; - -export type FileResponseData = { - body?: never; - path: { - id: string; - /** - * api-version should be required in standalone clients - */ - 'api-version': string; - }; - query?: never; - url: '/api/v{api-version}/file/{id}'; -}; - -export type FileResponseResponses = { - /** - * Success - */ - 200: Blob | File; -}; - -export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; - -export type ComplexTypesData = { - body?: never; - path?: never; - query: { - /** - * Parameter containing object - */ - parameterObject: { - first?: { - second?: { - third?: string; - }; - }; - }; - /** - * Parameter containing reference - */ - parameterReference: ModelWithString; - }; - url: '/api/v{api-version}/complex'; -}; - -export type ComplexTypesErrors = { - /** - * 400 `server` error - */ - 400: unknown; - /** - * 500 server error - */ - 500: unknown; -}; - -export type ComplexTypesResponses = { - /** - * Successful response - */ - 200: Array; -}; - -export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; - -export type MultipartResponseData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/multipart'; -}; - -export type MultipartResponseResponses = { - /** - * OK - */ - 200: { - file?: Blob | File; - metadata?: { - foo?: string; - bar?: string; - }; - }; -}; - -export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; - -export type MultipartRequestData = { - body?: { - content?: Blob | File; - data?: ModelWithString | null; - }; - path?: never; - query?: never; - url: '/api/v{api-version}/multipart'; -}; - -export type ComplexParamsData = { - body?: { - readonly key: string | null; - name: string | null; - enabled?: boolean; - type: 'Monkey' | 'Horse' | 'Bird'; - listOfModels?: Array | null; - listOfStrings?: Array | null; - parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; - readonly user?: { - readonly id?: number; - readonly name?: string | null; - }; - }; - path: { - id: number; - /** - * api-version should be required in standalone clients - */ - 'api-version': string; - }; - query?: never; - url: '/api/v{api-version}/complex/{id}'; -}; - -export type ComplexParamsResponses = { - /** - * Success - */ - 200: ModelWithString; -}; - -export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; - -export type CallWithResultFromHeaderData = { - body?: never; - path?: never; - query?: never; - url: '/api/v{api-version}/header'; -}; - -export type CallWithResultFromHeaderErrors = { - /** - * 400 server error - */ - 400: unknown; - /** - * 500 server error - */ - 500: unknown; -}; - -export type CallWithResultFromHeaderResponses = { - /** - * Successful response - */ - 200: unknown; -}; - -export type TestErrorCodeData = { - body?: never; - path?: never; - query: { - /** - * Status code to return - */ - status: number; - }; - url: '/api/v{api-version}/error'; -}; - -export type TestErrorCodeErrors = { - /** - * Custom message: Internal Server Error - */ - 500: unknown; - /** - * Custom message: Not Implemented - */ - 501: unknown; - /** - * Custom message: Bad Gateway - */ - 502: unknown; - /** - * Custom message: Service Unavailable - */ - 503: unknown; -}; - -export type TestErrorCodeResponses = { - /** - * Custom message: Successful response - */ - 200: unknown; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Data = { - body?: never; - path?: never; - query: { - /** - * Dummy input param - */ - nonAsciiParamæøåÆØÅöôêÊ: number; - }; - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { - /** - * Successful response - */ - 200: Array; -}; - -export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; - -export type PutWithFormUrlEncodedData = { - body: ArrayWithStrings; - path?: never; - query?: never; - url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; -}; - -export type ClientOptions = { - baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts index 541563521..2c34871f1 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts index 00251fe90..6850887fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/@tanstack/angular-query-experimental.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/angular-query-experimental'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions, Options> => { - const mutationOptions: MutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions, Options> => { + const mutationOptions: MutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts index 0d7f2d3d0..fda250e99 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/@tanstack/angular-query-experimental.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/angular-query-experimental'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions> => { - const mutationOptions: MutationOptions> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions> => { + const mutationOptions: MutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts index 0b3f03acd..cc71b7997 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/@tanstack/angular-query-experimental.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts index abb85ef9a..45e48e977 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Us } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts index 6fe7e3c87..ade1691a2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/@tanstack/react-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions, Options> => { - const mutationOptions: UseMutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions, Options> => { + const mutationOptions: UseMutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts index 1972de130..c4d031451 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/@tanstack/react-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/react-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions> => { - const mutationOptions: UseMutationOptions> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions> => { + const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts index 497cf4d39..80cf0ec00 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): UseMutati } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts index c5f84b545..893e5f52d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts index 56fd9e7bb..bddcb34e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/@tanstack/solid-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/solid-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions, Options> => { - const mutationOptions: MutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions, Options> => { + const mutationOptions: MutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts index 22270de65..e150db91b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/@tanstack/solid-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/solid-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions> => { - const mutationOptions: MutationOptions> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions> => { + const mutationOptions: MutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts index 60c022a12..392d84621 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/@tanstack/solid-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts index dea24b56c..1086c2202 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Mu } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts index 47a53470b..822ebb27d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/@tanstack/svelte-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/svelte-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions, Options> => { - const mutationOptions: MutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions, Options> => { + const mutationOptions: MutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts index fa766723e..e883dc537 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/@tanstack/svelte-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/svelte-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): MutationOptions> => { - const mutationOptions: MutationOptions> = { +export const deleteFooMutation = (options?: Partial>): MutationOptions> => { + const mutationOptions: MutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts index 6e7ff65de..98f162beb 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/@tanstack/svelte-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): MutationO } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts index e36dbe8a8..6c866b7bf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { Options } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutMutation = (options?: Partial>): Us } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts index 778ba43e8..353557eb6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -20,14 +20,14 @@ export type Options(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); @@ -36,14 +36,14 @@ class BarService { class FooService { public static post(options?: Options) { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); } public static put(options?: Options) { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); @@ -53,7 +53,7 @@ class FooService { export class FooBazService { public static getFoo(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); @@ -63,10 +63,10 @@ export class FooBazService { export class BarBazService { public static getFooBar(options?: Options) { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); } static fooService = FooService; -} \ No newline at end of file +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts index 1b98b18e1..c86860577 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/@tanstack/vue-query.gen.ts @@ -2,9 +2,9 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/vue-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; import type { AxiosError } from 'axios'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -17,7 +17,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? _heyApiClient).getConfig().baseURL } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseURL: options?.baseURL || (options?.client ?? client).getConfig().baseURL } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -207,8 +207,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions, Options> => { - const mutationOptions: UseMutationOptions, Options> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions, Options> => { + const mutationOptions: UseMutationOptions, Options> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -797,4 +797,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseURL: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts index 57b3bf7e3..cac41b947 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/no+tag', ...options, @@ -45,14 +45,14 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple/$count', ...options @@ -60,7 +60,7 @@ export const apiVVersionODataControllerCount = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/simple:operation', ...options @@ -68,63 +68,63 @@ export const getApiVbyApiVersionSimpleOperation = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -134,14 +134,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -152,7 +152,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -163,7 +163,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -174,7 +174,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/parameters', ...options, @@ -186,7 +186,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -197,7 +197,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -209,63 +209,63 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options @@ -273,7 +273,7 @@ export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/multiple-tags/a', ...options @@ -281,21 +281,21 @@ export const dummyA = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -303,7 +303,7 @@ export const callWithDuplicateResponses = }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/response', ...options @@ -311,14 +311,14 @@ export const callWithResponses = (options? }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/types', ...options @@ -326,7 +326,7 @@ export const types = (options: Options(options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, responseType: 'json', url: '/api/v{api-version}/upload', @@ -339,7 +339,7 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'blob', url: '/api/v{api-version}/file/{id}', ...options @@ -347,7 +347,7 @@ export const fileResponse = (options: Opti }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ responseType: 'json', url: '/api/v{api-version}/complex', ...options @@ -355,14 +355,14 @@ export const complexTypes = (options: Opti }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -374,7 +374,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ responseType: 'json', url: '/api/v{api-version}/complex/{id}', ...options, @@ -386,21 +386,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ responseType: 'json', url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options @@ -411,7 +411,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -420,4 +420,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts index 99c884c5a..eac22bf7c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseURL: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts index c75fd9799..c21b03b97 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/@tanstack/vue-query.gen.ts @@ -2,8 +2,8 @@ import { type Options, export_, patchApiVbyApiVersionNoTag, import_, fooWow, apiVVersionODataControllerCount, getApiVbyApiVersionSimpleOperation, deleteCallWithoutParametersAndResponse, getCallWithoutParametersAndResponse, patchCallWithoutParametersAndResponse, postCallWithoutParametersAndResponse, putCallWithoutParametersAndResponse, deleteFoo, callWithDescriptions, deprecatedCall, callWithParameters, callWithWeirdParameterNames, getCallWithOptionalParam, postCallWithOptionalParam, postApiVbyApiVersionRequestBody, postApiVbyApiVersionFormData, callWithDefaultParameters, callWithDefaultOptionalParameters, callToTestOrderOfParams, duplicateName, duplicateName2, duplicateName3, duplicateName4, callWithNoContentResponse, callWithResponseAndNoContentResponse, dummyA, dummyB, callWithResponse, callWithDuplicateResponses, callWithResponses, collectionFormat, types, uploadFile, fileResponse, complexTypes, multipartResponse, multipartRequest, complexParams, callWithResultFromHeader, testErrorCode, nonAsciiæøåÆøÅöôêÊ字符串, putWithFormUrlEncoded } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError, infiniteQueryOptions, type InfiniteData } from '@tanstack/vue-query'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesError, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesError, CallWithResponsesResponse, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -206,8 +206,8 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions> => { - const mutationOptions: UseMutationOptions> = { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions> => { + const mutationOptions: UseMutationOptions> = { mutationFn: async (fnOptions) => { const { data } = await deleteFoo({ ...options, @@ -796,4 +796,4 @@ export const putWithFormUrlEncodedMutation = (options?: Partial = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts index e79f50b13..17622c66b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type TDataShape, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; -import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,21 +19,21 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no+tag', ...options }); }; export const patchApiVbyApiVersionNoTag = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/no+tag', ...options }); }; export const import_ = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/no+tag', ...options, headers: { @@ -44,84 +44,84 @@ export const import_ = (options: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/no+tag', ...options }); }; export const apiVVersionODataControllerCount = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple/$count', ...options }); }; export const getApiVbyApiVersionSimpleOperation = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/simple:operation', ...options }); }; export const deleteCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/simple', ...options }); }; export const getCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/simple', ...options }); }; export const headCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).head({ + return (options?.client ?? client).head({ url: '/api/v{api-version}/simple', ...options }); }; export const optionsCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).options({ + return (options?.client ?? client).options({ url: '/api/v{api-version}/simple', ...options }); }; export const patchCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).patch({ + return (options?.client ?? client).patch({ url: '/api/v{api-version}/simple', ...options }); }; export const postCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/simple', ...options }); }; export const putCallWithoutParametersAndResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/simple', ...options }); }; -export const deleteFoo = (options: Options) => { - return (options.client ?? _heyApiClient).delete({ +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options }); }; export const callWithDescriptions = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/descriptions', ...options }); @@ -131,14 +131,14 @@ export const callWithDescriptions = (optio * @deprecated */ export const deprecatedCall = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/deprecated', ...options }); }; export const callWithParameters = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameterPath}', ...options, headers: { @@ -149,7 +149,7 @@ export const callWithParameters = (options }; export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', ...options, headers: { @@ -160,7 +160,7 @@ export const callWithWeirdParameterNames = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -171,7 +171,7 @@ export const getCallWithOptionalParam = (o }; export const postCallWithOptionalParam = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/parameters', ...options, headers: { @@ -182,7 +182,7 @@ export const postCallWithOptionalParam = ( }; export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/requestBody', ...options, headers: { @@ -193,7 +193,7 @@ export const postApiVbyApiVersionRequestBody = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/formData', ...options, @@ -205,119 +205,119 @@ export const postApiVbyApiVersionFormData = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/defaults', ...options }); }; export const callWithDefaultOptionalParameters = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/defaults', ...options }); }; export const callToTestOrderOfParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/defaults', ...options }); }; export const duplicateName = (options?: Options) => { - return (options?.client ?? _heyApiClient).delete({ + return (options?.client ?? client).delete({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName2 = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName3 = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/duplicate', ...options }); }; export const duplicateName4 = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/duplicate', ...options }); }; export const callWithNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/no-content', ...options }); }; export const callWithResponseAndNoContentResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/response-and-no-content', ...options }); }; export const dummyA = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/a', ...options }); }; export const dummyB = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multiple-tags/b', ...options }); }; export const callWithResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/response', ...options }); }; export const callWithDuplicateResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/response', ...options }); }; export const callWithResponses = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/api/v{api-version}/response', ...options }); }; export const collectionFormat = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/collectionFormat', ...options }); }; export const types = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/types', ...options }); }; export const uploadFile = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/upload', ...options, @@ -329,28 +329,28 @@ export const uploadFile = (options: Option }; export const fileResponse = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/file/{id}', ...options }); }; export const complexTypes = (options: Options) => { - return (options.client ?? _heyApiClient).get({ + return (options.client ?? client).get({ url: '/api/v{api-version}/complex', ...options }); }; export const multipartResponse = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/api/v{api-version}/multipart', ...options }); }; export const multipartRequest = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ ...formDataBodySerializer, url: '/api/v{api-version}/multipart', ...options, @@ -362,7 +362,7 @@ export const multipartRequest = (options?: }; export const complexParams = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ url: '/api/v{api-version}/complex/{id}', ...options, headers: { @@ -373,21 +373,21 @@ export const complexParams = (options: Opt }; export const callWithResultFromHeader = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/api/v{api-version}/header', ...options }); }; export const testErrorCode = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/error', ...options }); }; export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).post({ + return (options.client ?? client).post({ url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options }); @@ -397,7 +397,7 @@ export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { - return (options.client ?? _heyApiClient).put({ + return (options.client ?? client).put({ ...urlSearchParamsBodySerializer, url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', ...options, @@ -406,4 +406,4 @@ export const putWithFormUrlEncoded = (opti ...options.headers } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts index b15071c1c..463216f2d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/@tanstack/vue-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -128,4 +128,4 @@ export const fooBarPutC = (options?: Partial>): UseMutati } }; return mutationOptions; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts index 7b36e2cc5..30f73c51c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,43 +19,43 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); }; export const fooPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo', ...options }); }; export const fooPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo', ...options }); }; export const getFooBar = (options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo/bar', ...options }); }; export const fooBarPost = (options?: Options) => { - return (options?.client ?? _heyApiClient).post({ + return (options?.client ?? client).post({ url: '/foo/bar', ...options }); }; export const fooBarPut = (options?: Options) => { - return (options?.client ?? _heyApiClient).put({ + return (options?.client ?? client).put({ url: '/foo/bar', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts index e8d29ac66..4001df3e9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/types.gen.ts @@ -98,4 +98,4 @@ export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/fastify.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/fastify.gen.ts index 03f6f3f43..f7b237f6a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/fastify.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/fastify.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { ImportData, ImportResponses, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, DeleteFooData3, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseResponses, DummyAResponses, DummyBResponses, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import type { ImportData, ImportResponses, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseResponses, DummyAResponses, DummyBResponses, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; import type { RouteHandler } from 'fastify'; export type RouteHandlers = { @@ -16,8 +16,8 @@ export type RouteHandlers = { Reply: GetApiVbyApiVersionSimpleOperationResponses; }>; deleteFoo: RouteHandler<{ - Headers: DeleteFooData3['headers']; - Params: DeleteFooData3['path']; + Headers: DeleteFooData['headers']; + Params: DeleteFooData['path']; }>; callWithDescriptions: RouteHandler<{ Querystring?: CallWithDescriptionsData['query']; @@ -127,4 +127,4 @@ export type RouteHandlers = { putWithFormUrlEncoded: RouteHandler<{ Body: PutWithFormUrlEncodedData['body']; }>; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts index a6ae7c816..8bfc7d0f5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts @@ -2060,4 +2060,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts index a5ad1f87c..f59a1aa5d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts @@ -1783,4 +1783,4 @@ export const vPutWithFormUrlEncodedData = v.object({ body: vArrayWithStrings, path: v.optional(v.never()), query: v.optional(v.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/types.gen.ts index 698c31dfe..ec2aea840 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/types.gen.ts @@ -28,4 +28,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/types.gen.ts index bf9831f75..a40131f08 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-all-of-ref/types.gen.ts @@ -13,4 +13,4 @@ export type Bar = Foo & { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/types.gen.ts index b001001df..2faa0ef99 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-any-of-ref/types.gen.ts @@ -11,4 +11,4 @@ export type Bar = Foo & { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/types.gen.ts index b001001df..2faa0ef99 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/required-one-of-ref/types.gen.ts @@ -11,4 +11,4 @@ export type Bar = Foo & { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/types.gen.ts index 7fc17b795..1db5e5052 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/types.gen.ts @@ -38,4 +38,4 @@ export type Foo = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts index 01d8e66df..5bd057088 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/valibot.gen.ts @@ -34,4 +34,4 @@ export const vFoo = v.object({ integerUint64: v.optional(v.literal(BigInt('18446744073709551615'))), stringInt64: v.optional(v.literal(BigInt('-9223372036854775808'))), stringUint64: v.optional(v.literal(BigInt('18446744073709551615'))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/sdk.gen.ts index 265757467..2b1dad28c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { in: 'query', @@ -33,7 +33,7 @@ export const getFoo = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { in: 'cookie', @@ -44,4 +44,4 @@ export const getBar = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/sdk.gen.ts index 02b1b6f72..5f3be6607 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,8 +19,8 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ url: '/foo', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/types.gen.ts index 884795c3f..579f645ec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/types.gen.ts @@ -16,4 +16,4 @@ export type GetFooResponses = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/sdk.gen.ts index efd68f39a..8e5659281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'bearer', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/sdk.gen.ts index efd68f39a..8e5659281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'bearer', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/sdk.gen.ts index efd68f39a..8e5659281 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { scheme: 'bearer', @@ -29,4 +29,4 @@ export const getFoo = (options?: Options = export const client = createClient(createConfig({ baseUrl: 'https://foo.com/v1' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/types.gen.ts index fa745dd45..02482e56a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/types.gen.ts @@ -18,4 +18,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: 'https://foo.com/v1' | `${string}://${string}/v1` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/sdk.gen.ts index a25847202..40a25a497 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,8 +22,8 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).sse.get({ + return (options?.client ?? client).sse.get({ url: '/event', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/types.gen.ts index 4c2fc0ef9..ea6b3e42a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/types.gen.ts @@ -524,4 +524,4 @@ export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscrib export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/sdk.gen.ts index 9fda75e78..1f0d8da6e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,9 +22,9 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).sse.get({ + return (options?.client ?? client).sse.get({ responseType: 'text', url: '/event', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/types.gen.ts index 3794af38d..a360dc82e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/types.gen.ts @@ -524,4 +524,4 @@ export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscrib export type ClientOptions = { baseURL: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/sdk.gen.ts index a25847202..40a25a497 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,8 +22,8 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).sse.get({ + return (options?.client ?? client).sse.get({ url: '/event', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/types.gen.ts index 4c2fc0ef9..ea6b3e42a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/types.gen.ts @@ -524,4 +524,4 @@ export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscrib export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/sdk.gen.ts index a25847202..40a25a497 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,8 +22,8 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).sse.get({ + return (options?.client ?? client).sse.get({ url: '/event', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/types.gen.ts index 4c2fc0ef9..ea6b3e42a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/types.gen.ts @@ -524,4 +524,4 @@ export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscrib export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/sdk.gen.ts index 7f13d88c6..b72775ca4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Composable, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Composable, Client, TDataShape } from './client'; import type { EventSubscribeResponse, EventSubscribeData } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -22,8 +22,8 @@ export type Options(options: Options) => { - return (options.client ?? _heyApiClient).sse.get({ + return (options.client ?? client).sse.get({ url: '/event', ...options }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/types.gen.ts index 3794af38d..a360dc82e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/types.gen.ts @@ -524,4 +524,4 @@ export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscrib export type ClientOptions = { baseURL: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/transformers.gen.ts index 0b520225d..9336baf5a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/transformers.gen.ts @@ -32,4 +32,4 @@ const fooSchemaResponseTransformer = (data: any) => { export const getFooResponseTransformer = async (data: any): Promise => { data = fooSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/types.gen.ts index 25ae9771c..e2bd16164 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/types.gen.ts @@ -43,4 +43,4 @@ export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/transformers.gen.ts index 15b043f4f..c3a28994c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/transformers.gen.ts @@ -37,4 +37,4 @@ const nestedDateObjectSchemaResponseTransformer = (data: any) => { export const nestedDateObjectResponseTransformer = async (data: any): Promise => { data = nestedDateObjectSchemaResponseTransformer(data); return data; -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/types.gen.ts index 3bbe84e0e..ab403042b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/types.gen.ts @@ -50,4 +50,4 @@ export type NestedDateObjectResponse = NestedDateObjectResponses[keyof NestedDat export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/transformers.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/transformers.gen.ts index 5ad0b923d..fc50ee927 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/transformers.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/transformers.gen.ts @@ -8,4 +8,4 @@ export const getFooResponseTransformer = async (data: any): Promise = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/types.gen.ts index 42fec9097..6f56a6430 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/types.gen.ts @@ -156,4 +156,4 @@ export type PutFooWriteResponse = PutFooWriteResponses[keyof PutFooWriteResponse export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/types.gen.ts index 2589e80df..b507475fd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/type-invalid/types.gen.ts @@ -4,4 +4,4 @@ export type Foo = unknown; export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/types.gen.ts index a4f60d550..36097cc14 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/union-types/types.gen.ts @@ -6,4 +6,4 @@ export type Foo = { export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts index 284f1ae3b..c3c08a3d9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/valibot.gen.ts @@ -8,4 +8,4 @@ export const vFoo = v.object({ v.string(), v.bigint() ]), v.transform(x => BigInt(x)), v.minValue(BigInt('-9223372036854775808'), 'Invalid value: Expected int64 to be >= -2^63'), v.maxValue(BigInt('9223372036854775807'), 'Invalid value: Expected int64 to be <= 2^63-1'), v.minValue(BigInt(0)), v.maxValue(BigInt(100)))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts index ae09d1323..11af4d8fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/valibot.gen.ts @@ -13,4 +13,4 @@ export const vBar: v.GenericSchema = v.object({ export const vFoo: v.GenericSchema = v.object({ foo: vBar -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts index 6035a4b94..c32b0b517 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/valibot.gen.ts @@ -19,4 +19,4 @@ export const vQux: v.GenericSchema = v.lazy(() => { return vQux; }); -export const vBaz: v.GenericSchema = vQux; \ No newline at end of file +export const vBaz: v.GenericSchema = vQux; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts index 740a2db22..c54dd93e8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts @@ -73,4 +73,4 @@ export const vPostFooData = v.object({ body: vFoo3, path: v.optional(v.never()), query: v.optional(v.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts index 2cd346b03..3c12cbfaa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/valibot.gen.ts @@ -61,4 +61,4 @@ export const vPostFooData = v.object({ body: vFoo3, path: v.optional(v.never()), query: v.optional(v.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts index 665b622c6..3662ff489 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/valibot.gen.ts @@ -44,4 +44,4 @@ export const vPetStore = v.object({ vCatDetails ]) })) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts index 2cd346b03..3c12cbfaa 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/valibot.gen.ts @@ -61,4 +61,4 @@ export const vPostFooData = v.object({ body: vFoo3, path: v.optional(v.never()), query: v.optional(v.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/index.ts index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/index.ts @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/types.gen.ts index 5a7827aa4..e0db6ccda 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/types.gen.ts @@ -3309,4 +3309,4 @@ export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); }; -export type Webhooks = SessionUserPhoneCalloutRingingWebhookRequest | SessionUserRoomSystemCalloutRingingWebhookRequest | SessionRecordingStartedWebhookRequest | SessionRecordingResumedWebhookRequest | SessionLiveStreamingStoppedWebhookRequest | SessionStreamIngestionStoppedWebhookRequest | SessionUserRoomSystemCalloutRejectedWebhookRequest | SessionAlertWebhookRequest | SessionSharingEndedWebhookRequest | SessionRecordingPausedWebhookRequest | SessionEndedWebhookRequest | SessionStartedWebhookRequest | SessionStreamIngestionUnbindWebhookRequest | SessionLiveStreamingStartedWebhookRequest | SessionUserRoomSystemCalloutMissedWebhookRequest | SessionUserPhoneCalloutAcceptedWebhookRequest | SessionUserLeftWebhookRequest | SessionSharingStartedWebhookRequest | SessionUserPhoneCalloutCanceledWebhookRequest | SessionRecordingTranscriptCompletedWebhookRequest | SessionRecordingDeletedWebhookRequest | SessionUserRoomSystemCalloutFailedWebhookRequest | SessionRecordingCompletedWebhookRequest | SessionRecordingTranscriptFailedWebhookRequest | SessionRecordingTrashedWebhookRequest | SessionUserJoinedWebhookRequest | SessionStreamIngestionStartedWebhookRequest | SessionStreamIngestionConnectedWebhookRequest | SessionStreamIngestionDisconnectedWebhookRequest | SessionRecordingRecoveredWebhookRequest | SessionUserPhoneCalloutMissedWebhookRequest | SessionUserPhoneCalloutRejectedWebhookRequest | SessionUserRoomSystemCalloutAcceptedWebhookRequest | SessionRecordingStoppedWebhookRequest; \ No newline at end of file +export type Webhooks = SessionUserPhoneCalloutRingingWebhookRequest | SessionUserRoomSystemCalloutRingingWebhookRequest | SessionRecordingStartedWebhookRequest | SessionRecordingResumedWebhookRequest | SessionLiveStreamingStoppedWebhookRequest | SessionStreamIngestionStoppedWebhookRequest | SessionUserRoomSystemCalloutRejectedWebhookRequest | SessionAlertWebhookRequest | SessionSharingEndedWebhookRequest | SessionRecordingPausedWebhookRequest | SessionEndedWebhookRequest | SessionStartedWebhookRequest | SessionStreamIngestionUnbindWebhookRequest | SessionLiveStreamingStartedWebhookRequest | SessionUserRoomSystemCalloutMissedWebhookRequest | SessionUserPhoneCalloutAcceptedWebhookRequest | SessionUserLeftWebhookRequest | SessionSharingStartedWebhookRequest | SessionUserPhoneCalloutCanceledWebhookRequest | SessionRecordingTranscriptCompletedWebhookRequest | SessionRecordingDeletedWebhookRequest | SessionUserRoomSystemCalloutFailedWebhookRequest | SessionRecordingCompletedWebhookRequest | SessionRecordingTranscriptFailedWebhookRequest | SessionRecordingTrashedWebhookRequest | SessionUserJoinedWebhookRequest | SessionStreamIngestionStartedWebhookRequest | SessionStreamIngestionConnectedWebhookRequest | SessionStreamIngestionDisconnectedWebhookRequest | SessionRecordingRecoveredWebhookRequest | SessionUserPhoneCalloutMissedWebhookRequest | SessionUserPhoneCalloutRejectedWebhookRequest | SessionUserRoomSystemCalloutAcceptedWebhookRequest | SessionRecordingStoppedWebhookRequest; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts index 5aed852b0..4eddc12b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/valibot.gen.ts @@ -1278,4 +1278,4 @@ export const vSessionRecordingStoppedWebhookRequest = v.object({ })), path: v.optional(v.never()), query: v.optional(v.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/zod.gen.ts index 9aefbbb35..996228043 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/zod.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/webhooks/zod.gen.ts @@ -1066,4 +1066,4 @@ export const zSessionRecordingStoppedWebhookRequest = z.object({ })), path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/angular-query-experimental.gen.ts index f493c9edd..2a7a9213e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/angular-query-experimental.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/angular-query-experimental'; import type { GetFooData, GetBarData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -82,4 +82,4 @@ export const getBarOptions = (options?: Options) => { path: '/bar' } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/react-query.gen.ts index 2a0899cd8..39a86f05a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/react-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/react-query'; import type { GetFooData, GetBarData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -82,4 +82,4 @@ export const getBarOptions = (options?: Options) => { path: '/bar' } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/solid-query.gen.ts index f74078376..ae71709ec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/solid-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/solid-query'; import type { GetFooData, GetBarData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -82,4 +82,4 @@ export const getBarOptions = (options?: Options) => { path: '/bar' } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/svelte-query.gen.ts index ed253e483..291ad4e82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/svelte-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/svelte-query'; import type { GetFooData, GetBarData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -82,4 +82,4 @@ export const getBarOptions = (options?: Options) => { path: '/bar' } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/vue-query.gen.ts index d92ade616..0c5ff38a7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/@tanstack/vue-query.gen.ts @@ -3,7 +3,7 @@ import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/vue-query'; import type { GetFooData, GetBarData } from '../types.gen'; -import { client as _heyApiClient } from '../client.gen'; +import { client } from '../client.gen'; export type QueryKey = [ Pick & { @@ -16,7 +16,7 @@ export type QueryKey = [ const createQueryKey = (id: string, options?: TOptions, infinite?: boolean, tags?: ReadonlyArray): [ QueryKey[0] ] => { - const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? _heyApiClient).getConfig().baseUrl } as QueryKey[0]; + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; if (infinite) { params._infinite = infinite; } @@ -82,4 +82,4 @@ export const getBarOptions = (options?: Options) => { path: '/bar' } }); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client.gen.ts index 163da4e54..fe57f118d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client.gen.ts @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts import type { ClientOptions } from './types.gen'; -import { type Config, type ClientOptions as DefaultClientOptions, createClient, createConfig } from './client'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; /** * The `createClientConfig()` function will be called on client initialization @@ -13,4 +13,4 @@ import { type Config, type ClientOptions as DefaultClientOptions, createClient, */ export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); \ No newline at end of file +export const client = createClient(createConfig()); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/index.ts index e64537d21..cc646f13a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/index.ts @@ -1,3 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts + export * from './types.gen'; -export * from './sdk.gen'; \ No newline at end of file +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/sdk.gen.ts index 265757467..2b1dad28c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/sdk.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/sdk.gen.ts @@ -1,8 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, TDataShape, Client } from './client'; +import type { Options as ClientOptions, Client, TDataShape } from './client'; import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; -import { client as _heyApiClient } from './client.gen'; +import { client } from './client.gen'; export type Options = ClientOptions & { /** @@ -19,7 +19,7 @@ export type Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { in: 'query', @@ -33,7 +33,7 @@ export const getFoo = (options?: Options(options?: Options) => { - return (options?.client ?? _heyApiClient).get({ + return (options?.client ?? client).get({ security: [ { in: 'cookie', @@ -44,4 +44,4 @@ export const getBar = (options?: Options = export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' -})); \ No newline at end of file +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/types.gen.ts.snap index 092e0e2f3..7ddcc37be 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/types.gen.ts.snap @@ -1990,4 +1990,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/index.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/index.ts.snap index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/index.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/index.ts.snap @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap index 092e0e2f3..7ddcc37be 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/types.gen.ts.snap @@ -1990,4 +1990,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/index.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/index.ts.snap index 56bade120..0339b6e31 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/index.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/index.ts.snap @@ -1,2 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; \ No newline at end of file + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap index 092e0e2f3..7ddcc37be 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types_no_tree/types.gen.ts.snap @@ -1990,4 +1990,4 @@ export type PutWithFormUrlEncodedData = { export type ClientOptions = { baseUrl: 'http://localhost:3000/base' | (string & {}); -}; \ No newline at end of file +}; diff --git a/packages/openapi-ts-tests/main/test/custom/client/plugin.ts b/packages/openapi-ts-tests/main/test/custom/client/plugin.ts index 19726b5b8..fbac79053 100644 --- a/packages/openapi-ts-tests/main/test/custom/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/custom/client/plugin.ts @@ -1,3 +1,4 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -7,17 +8,42 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type Config = Client.Config & { +type SelectorType = 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Pick) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} + +export type Config = Client.Config & { /** * Plugin name. Must be unique. */ name: string; }; -export type MyClientPlugin = DefinePlugin; +export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: __filename, + }), config: clientDefaultConfig, handler: clientPluginHandler as MyClientPlugin['Handler'], name: __filename, diff --git a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts index 592ceda11..90a582af6 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -37,8 +37,9 @@ export default defineConfig(() => { // 'invalid', // 'openai.yaml', // 'full.yaml', - 'opencode.yaml', - // 'zoom-video-sdk.json', + // 'opencode.yaml', + // 'validators-circular-ref-2.yaml', + 'zoom-video-sdk.json', ), // https://registry.scalar.com/@lubos-heyapi-dev-team/apis/demo-api-scalar-galaxy/latest?format=json // path: 'scalar:@lubos-heyapi-dev-team/demo-api-scalar-galaxy', @@ -67,7 +68,7 @@ export default defineConfig(() => { // case: 'snake_case', clean: true, // format: 'prettier', - // indexFile: false, + indexFile: false, // lint: 'eslint', path: path.resolve(__dirname, 'generated', 'sample'), // tsConfigPath: path.resolve( @@ -130,14 +131,14 @@ export default defineConfig(() => { validate_EXPERIMENTAL: true, }, plugins: [ - // customClientPlugin({ - // baseUrl: false, - // }), + customClientPlugin({ + baseUrl: false, + }), // myClientPlugin(), { // baseUrl: false, - // exportFromIndex: true, - name: '@hey-api/client-fetch', + exportFromIndex: true, + // name: '@hey-api/client-fetch', // name: 'legacy/angular', // strictBaseUrl: true, // throwOnError: true, @@ -149,7 +150,7 @@ export default defineConfig(() => { // case: 'PascalCase', // constantsIgnoreNull: true, // enabled: false, - // mode: 'typescript', + mode: 'javascript', }, // errors: { // error: '他們_error_{{name}}', @@ -162,10 +163,10 @@ export default defineConfig(() => { // response: '他_response_{{name}}', // }, // tree: true, - webhooks: { - name: 'Webby{{name}}Hook', - payload: '{{name}}WebhookEvent', - }, + // webhooks: { + // name: 'Webby{{name}}Hook', + // payload: '{{name}}WebhookEvent', + // }, }, { // asClass: true, @@ -175,7 +176,7 @@ export default defineConfig(() => { // client: false, // include... // instance: true, - name: '@hey-api/sdk', + // name: '@hey-api/sdk', // operationId: false, // params: 'experiment', // responseStyle: 'data', @@ -183,8 +184,8 @@ export default defineConfig(() => { // transformer: true, // validator: 'valibot', // validator: { - // request: 'zod', - // response: 'zod', + // request: 'valibot', + // response: 'valibot', // }, }, { @@ -208,11 +209,11 @@ export default defineConfig(() => { // mutationOptions: { // name: '{{name}}MO', // }, - name: '@tanstack/react-query', + // name: '@tanstack/react-query', // queryKeys: { // name: '{{name}}QK', // }, - queryOptions: false, + // queryOptions: false, // queryOptions: { // name: '{{name}}QO', // }, @@ -232,12 +233,12 @@ export default defineConfig(() => { // case: 'SCREAMING_SNAKE_CASE', // comments: false, // definitions: 'z{{name}}Definition', - exportFromIndex: true, + // exportFromIndex: true, // metadata: true, - name: 'valibot', + // name: 'valibot', // requests: { - // // case: 'SCREAMING_SNAKE_CASE', - // name: 'z{{name}}TestData', + // case: 'PascalCase', + // name: '{{name}}Data', // }, // responses: { // // case: 'snake_case', @@ -250,7 +251,7 @@ export default defineConfig(() => { { // case: 'snake_case', // comments: false, - compatibilityVersion: 3, + compatibilityVersion: 4, dates: { local: true, // offset: true, @@ -263,7 +264,7 @@ export default defineConfig(() => { }, exportFromIndex: true, metadata: true, - name: 'zod', + // name: 'zod', // requests: { // // case: 'SCREAMING_SNAKE_CASE', // // name: 'z{{name}}TestData', @@ -278,11 +279,11 @@ export default defineConfig(() => { // infer: 'F{{name}}ResponseZodType', // }, // }, - // types: { - // infer: { - // case: 'snake_case', - // }, - // }, + types: { + // infer: { + // case: 'snake_case', + // }, + }, }, { exportFromIndex: true, @@ -290,15 +291,18 @@ export default defineConfig(() => { // type: 'json', }, { - // httpRequest - // httpResource exportFromIndex: true, + httpRequests: { + asClass: true, + }, + httpResources: { + asClass: true, + }, // name: '@angular/common', }, { - // groupByTag: true, // mutationOptions: '{{name}}Mutationssss', - name: '@pinia/colada', + // name: '@pinia/colada', // queryOptions: { // name: '{{name}}Queryyyyy', // }, diff --git a/packages/openapi-ts-tests/main/test/plugins.test.ts b/packages/openapi-ts-tests/main/test/plugins.test.ts index 72de256fc..4d5e9e832 100644 --- a/packages/openapi-ts-tests/main/test/plugins.test.ts +++ b/packages/openapi-ts-tests/main/test/plugins.test.ts @@ -519,20 +519,6 @@ for (const version of versions) { }), description: 'generate Fetch API client with Pinia Colada plugin', }, - { - config: createConfig({ - output: 'group-by-tag', - plugins: [ - { - groupByTag: true, - name: '@pinia/colada', - }, - '@hey-api/client-fetch', - ], - }), - description: - 'generates Fetch API client with Pinia Colada plugin group by tag', - }, ]; it.each(scenarios)('$description', async ({ config }) => { diff --git a/packages/openapi-ts/src/generate/__tests__/file.test.ts b/packages/openapi-ts/src/generate/__tests__/file.test.ts new file mode 100644 index 000000000..ea001c323 --- /dev/null +++ b/packages/openapi-ts/src/generate/__tests__/file.test.ts @@ -0,0 +1,35 @@ +import { describe, expect, it } from 'vitest'; + +import { splitNameAndExtension } from '../file'; + +describe('splitNameAndExtension', () => { + it('should split filename with extension correctly', () => { + const result = splitNameAndExtension('document.pdf'); + expect(result).toEqual({ extension: 'pdf', name: 'document' }); + }); + + it('should handle filename without extension', () => { + const result = splitNameAndExtension('README'); + expect(result).toEqual({ extension: '', name: 'README' }); + }); + + it('should handle filename with multiple dots', () => { + const result = splitNameAndExtension('my.file.name.txt'); + expect(result).toEqual({ extension: 'txt', name: 'my.file.name' }); + }); + + it('should handle empty string', () => { + const result = splitNameAndExtension(''); + expect(result).toEqual({ extension: '', name: '' }); + }); + + it('should handle filename with uppercase extension', () => { + const result = splitNameAndExtension('image.PNG'); + expect(result).toEqual({ extension: 'PNG', name: 'image' }); + }); + + it('should handle extension with numbers', () => { + const result = splitNameAndExtension('video.mp4'); + expect(result).toEqual({ extension: 'mp4', name: 'video' }); + }); +}); diff --git a/packages/openapi-ts/src/generate/client.ts b/packages/openapi-ts/src/generate/client.ts index 38f8300bd..4dae89d5b 100644 --- a/packages/openapi-ts/src/generate/client.ts +++ b/packages/openapi-ts/src/generate/client.ts @@ -7,7 +7,6 @@ import ts from 'typescript'; import type { Client } from '../plugins/@hey-api/client-core/types'; import { getClientPlugin } from '../plugins/@hey-api/client-core/utils'; import type { DefinePlugin } from '../plugins/types'; -import type { ImportExportItemObject } from '../tsc/utils'; import type { Config } from '../types/config'; import { splitNameAndExtension } from './file'; import { ensureDirSync, relativeModulePath } from './utils'; @@ -53,17 +52,6 @@ export const clientModulePath = ({ return client.name; }; -export const clientApi = { - Options: { - asType: true, - name: 'Options', - }, - OptionsLegacyParser: { - asType: true, - name: 'OptionsLegacyParser', - }, -} satisfies Record; - /** * Recursively copies files and directories. * This is a PnP-compatible alternative to fs.cpSync that works with Yarn PnP's diff --git a/packages/openapi-ts/src/generate/file.ts b/packages/openapi-ts/src/generate/file.ts new file mode 100644 index 000000000..44939bc69 --- /dev/null +++ b/packages/openapi-ts/src/generate/file.ts @@ -0,0 +1,275 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +import ts from 'typescript'; + +import type { IR } from '../ir/types'; +import { tsc } from '../tsc'; +import { type ImportExportItemObject, tsNodeToString } from '../tsc/utils'; +import { ensureDirSync } from './utils'; + +type FileImportResult< + Name extends string | undefined = string | undefined, + Alias extends string | undefined = undefined, +> = { + asType?: boolean; + name: Alias extends string ? Alias : Name; +}; + +export class GeneratedFile { + /** + * Should the exports from this file be re-exported in the index barrel file? + */ + private _exportFromIndex: boolean; + private _headers: Array = []; + private _id: string; + private _imports = new Map>(); + private _items: Array = []; + private _name: string; + private _path: string; + + public constructor({ + dir, + exportFromIndex = false, + header = true, + id, + name, + }: { + dir: string; + /** + * Should the exports from this file be re-exported in the index barrel file? + */ + exportFromIndex?: boolean; + header?: boolean; + /** + * Unique file ID. Used to generate correct relative paths to the file. + * This should be refactored later as it's basically the file name unless + * nested inside another folder. + */ + id: string; + name: string; + }) { + this._exportFromIndex = exportFromIndex; + this._id = id; + this._name = this._setName(name); + this._path = path.resolve(dir, this._name); + + if (header) { + this._headers.push( + '// This file is auto-generated by @hey-api/openapi-ts', + ); + } + } + + public add(...nodes: Array) { + this._items = this._items.concat(nodes); + } + + public get exportFromIndex(): boolean { + return this._exportFromIndex; + } + + public get id(): string { + return this._id; + } + + /** + * Adds an import to the provided module. Handles duplication, returns added + * import. Returns the imported name. If we import an aliased export, `name` + * will be equal to the specified `alias`. + */ + public import< + Name extends string | undefined = string | undefined, + Alias extends string | undefined = undefined, + >({ + module, + ...importedItem + }: ImportExportItemObject & { + module: string; + }): FileImportResult { + if (!importedItem.name) { + return { + name: undefined as any, + }; + } + + let moduleMap = this._imports.get(module); + + if (!moduleMap) { + moduleMap = new Map(); + this._imports.set(module, moduleMap); + } + + const match = moduleMap.get(importedItem.name); + if (match) { + return { + ...match, + name: (match.alias || match.name) as any, + }; + } + + moduleMap.set(importedItem.name, importedItem as any); + return { + ...importedItem, + name: (importedItem.alias || importedItem.name) as any, + }; + } + + public isEmpty() { + return !this._items.length; + } + + public nameWithoutExtension() { + const { name } = splitNameAndExtension(this._name); + return name; + } + + public relativePathToFile({ + context, + id, + }: { + context: IR.Context; + id: string; + }): string { + let filePath = ''; + + // relative file path + if (id.startsWith('.')) { + let configFileParts: Array = []; + // if providing a custom configuration file, relative paths must resolve + // relative to the configuration file. + if (context.config.configFile) { + const cfgParts = context.config.configFile.split('/'); + configFileParts = cfgParts.slice(0, cfgParts.length - 1); + } + filePath = path.resolve(process.cwd(), ...configFileParts, id); + } else { + const file = context.file({ id }); + if (!file) { + throw new Error(`File with id ${id} does not exist`); + } + filePath = file._path; + } + + const thisPathParts = this._path.split(path.sep); + const filePathParts = filePath.split(path.sep); + + let index = -1; + let relativePath = ''; + for (const part of thisPathParts) { + index += 1; + if (filePathParts[index] !== part) { + const pathArray = Array.from({ + length: thisPathParts.length - index, + }).fill(''); + const relativePathToFile = filePathParts.slice(index); + const relativeFolder = relativePathToFile.slice( + 0, + relativePathToFile.length - 1, + ); + if (relativeFolder.length) { + relativeFolder.push(''); + } + relativePath = + (pathArray.join('../') || './') + relativeFolder.join('/'); + break; + } + } + + const fileName = filePathParts[filePathParts.length - 1]!; + // TODO: parser - cache responses + return `${relativePath}${splitNameAndExtension(fileName).name}`; + } + + public remove(options?: Parameters[1]) { + fs.rmSync(this._path, options); + } + + /** + * Removes last node form the stack. Works as undo. + * + * @deprecated + */ + public removeNode_LEGACY() { + this._items = this._items.slice(0, this._items.length - 1); + } + + private _setName(fileName: string) { + if (fileName.includes('index')) { + return fileName; + } + + const { extension, name } = splitNameAndExtension(fileName); + return [name, 'gen', extension].filter(Boolean).join('.'); + } + + private _toString(separator: string, tsConfig: ts.ParsedCommandLine | null) { + let output: Array = []; + if (this._headers.length) { + output.push(this._headers.join('\n')); + } + + const shouldAppendJs = + tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext; + + const importsStringArray: Array = []; + + for (const [_module, moduleMap] of this._imports.entries()) { + const imports = Array.from(moduleMap.values()); + + let resolvedModule = _module; + if ( + shouldAppendJs && + (resolvedModule.startsWith('./') || resolvedModule.startsWith('../')) + ) { + if (resolvedModule === './client') { + resolvedModule = './client/index.js'; + } else { + resolvedModule = `${resolvedModule}.js`; + } + } + + const node = tsc.namedImportDeclarations({ + imports, + module: resolvedModule, + }); + importsStringArray.push(tsNodeToString({ node })); + } + if (importsStringArray.length) { + output.push(importsStringArray.join('\n')); + } + output = output.concat( + this._items.map((node) => + typeof node === 'string' + ? node + : tsNodeToString({ node, unescape: true }), + ), + ); + return output.join(separator); + } + + public write(separator = '\n', tsConfig: ts.ParsedCommandLine | null = null) { + if (this.isEmpty()) { + this.remove({ force: true }); + return; + } + + let dir = this._path; + if (typeof this._path === 'string') { + const parts = this._path.split(path.sep); + dir = parts.slice(0, parts.length - 1).join(path.sep); + } + ensureDirSync(dir); + fs.writeFileSync(this._path, this._toString(separator, tsConfig)); + } +} + +export const splitNameAndExtension = (fileName: string) => { + const match = fileName.match(/\.[0-9a-z]+$/i); + const extension = match ? match[0].slice(1) : ''; + const name = fileName.slice( + 0, + fileName.length - (extension ? extension.length + 1 : 0), + ); + return { extension, name }; +}; diff --git a/packages/openapi-ts/src/generate/file/__tests__/file.test.ts b/packages/openapi-ts/src/generate/file/__tests__/file.test.ts deleted file mode 100644 index aef55b1ea..000000000 --- a/packages/openapi-ts/src/generate/file/__tests__/file.test.ts +++ /dev/null @@ -1,380 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import { _test, splitNameAndExtension } from '../index'; -import type { Identifiers } from '../types'; - -const { ensureUniqueIdentifier, parseRef } = _test; - -describe('parseRef', () => { - it('should parse simple ref without properties', () => { - const ref = '#/components/schemas/User'; - const result = parseRef(ref); - expect(result).toEqual({ - name: 'User', - properties: [], - ref: '#/components/schemas/User', - }); - }); - - it('should parse ref with single property', () => { - const ref = '#/components/schemas/User/properties/name'; - const result = parseRef(ref); - expect(result).toEqual({ - name: 'User', - properties: ['name'], - ref: '#/components/schemas/User', - }); - }); - - it('should parse ref with multiple properties', () => { - const ref = '#/components/schemas/User/properties/address/properties/city'; - const result = parseRef(ref); - expect(result).toEqual({ - name: 'User', - properties: ['address', 'city'], - ref: '#/components/schemas/User', - }); - }); - - it('should handle ref with empty name', () => { - const ref = '#/components/schemas/'; - const result = parseRef(ref); - expect(result).toEqual({ - name: '', - properties: [], - ref: '#/components/schemas/', - }); - }); - - it('should throw error for invalid ref with empty property', () => { - const ref = '#/components/schemas/User/properties/'; - expect(() => parseRef(ref)).toThrow('Invalid $ref: ' + ref); - }); -}); - -describe('splitNameAndExtension', () => { - it('should split filename with extension correctly', () => { - const result = splitNameAndExtension('document.pdf'); - expect(result).toEqual({ extension: 'pdf', name: 'document' }); - }); - - it('should handle filename without extension', () => { - const result = splitNameAndExtension('README'); - expect(result).toEqual({ extension: '', name: 'README' }); - }); - - it('should handle filename with multiple dots', () => { - const result = splitNameAndExtension('my.file.name.txt'); - expect(result).toEqual({ extension: 'txt', name: 'my.file.name' }); - }); - - it('should handle empty string', () => { - const result = splitNameAndExtension(''); - expect(result).toEqual({ extension: '', name: '' }); - }); - - it('should handle filename with uppercase extension', () => { - const result = splitNameAndExtension('image.PNG'); - expect(result).toEqual({ extension: 'PNG', name: 'image' }); - }); - - it('should handle extension with numbers', () => { - const result = splitNameAndExtension('video.mp4'); - expect(result).toEqual({ extension: 'mp4', name: 'video' }); - }); -}); - -describe('ensureUniqueIdentifier', () => { - it('returns empty name when no name is parsed from ref', () => { - const identifiers: Identifiers = {}; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/', - case: 'camelCase', - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ - created: false, - name: '', - }); - }); - - it('returns existing name from namespace when ref exists', () => { - const identifiers: Identifiers = { - user: { - type: { - '#/components/User': { $ref: '#/components/User', name: 'User' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/User', - case: 'camelCase', - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ - created: false, - name: 'User', - }); - }); - - it('handles nested properties in ref', () => { - const identifiers: Identifiers = { - user: { - type: { - '#/components/User': { $ref: '#/components/User', name: 'User' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/User/properties/id', - case: 'camelCase', - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ - created: false, - name: "User['id']", - }); - }); - - it('applies nameTransformer and case transformation', () => { - const nameTransformer = (name: string) => `prefix${name}`; - const identifiers: Identifiers = { - user: { - type: {}, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/User', - case: 'camelCase', - create: true, - identifiers, - nameTransformer, - namespace: 'type', - }); - - expect(result).toEqual({ - created: true, - name: 'prefixUser', - }); - expect(identifiers).toHaveProperty('prefixuser', { - type: { - '#/components/User': { - $ref: '#/components/User', - name: 'prefixUser', - }, - prefixUser: { - $ref: '#/components/User', - name: 'prefixUser', - }, - }, - }); - }); - - it('resolves naming conflicts by appending count', () => { - const identifiers: Identifiers = { - user: { - type: { - user: { $ref: '#/components/Other', name: 'user' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/User', - case: 'camelCase', - create: true, - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ - created: true, - name: 'user2', - }); - expect(identifiers).toHaveProperty('user2', { - type: { - '#/components/User': { - $ref: '#/components/User', - name: 'user2', - }, - user2: { - $ref: '#/components/User', - name: 'user2', - }, - }, - }); - }); - - it('resolves naming conflicts with name transformer by appending count', () => { - const identifiers: Identifiers = { - user: { - type: { - user: { $ref: '#/components/Other', name: 'user' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/Foo', - case: 'camelCase', - create: true, - identifiers, - nameTransformer: () => 'user', - namespace: 'type', - }); - - expect(result).toEqual({ - created: true, - name: 'user2', - }); - expect(identifiers).toHaveProperty('user2', { - type: { - '#/components/Foo': { - $ref: '#/components/Foo', - name: 'user2', - }, - user2: { - $ref: '#/components/Foo', - name: 'user2', - }, - }, - }); - }); - - it('returns existing name when ref matches in namespace', () => { - const identifiers: Identifiers = { - user: { - type: { - '#/components/User': { $ref: '#/components/User', name: 'user' }, - user: { $ref: '#/components/User', name: 'user' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/User', - case: 'camelCase', - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ - created: false, - name: 'user', - }); - }); - - it('does not create new entry when create is false', () => { - const identifiers: Identifiers = {}; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/User', - case: 'camelCase', - create: false, - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ - created: false, - name: '', - }); - expect(identifiers).toEqual({ - user: {}, - }); - }); - - it('returns existing identifier if name collision matches same ref', () => { - const identifiers: Identifiers = { - user: { - type: { - User: { $ref: '#/components/schemas/User', name: 'User' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/schemas/User', - case: 'PascalCase', - create: true, - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ created: false, name: 'User' }); - }); - - it('creates a new identifier for enum if name collision matches non-enum', () => { - const identifiers: Identifiers = { - user: { - type: { - User: { $ref: '#/components/schemas/User', name: 'User' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/schemas/User', - case: 'PascalCase', - create: true, - identifiers, - namespace: 'enum', - }); - - expect(result).toEqual({ created: true, name: 'User2' }); - expect(identifiers).toHaveProperty('user2', { - enum: { - '#/components/schemas/User': { - $ref: '#/components/schemas/User', - name: 'User2', - }, - User2: { - $ref: '#/components/schemas/User', - name: 'User2', - }, - }, - }); - }); - - it('creates a new identifier for non-enum if name collision matches enum', () => { - const identifiers: Identifiers = { - user: { - enum: { - User: { $ref: '#/components/schemas/User', name: 'User' }, - }, - }, - }; - - const result = ensureUniqueIdentifier({ - $ref: '#/components/schemas/User', - case: 'PascalCase', - create: true, - identifiers, - namespace: 'type', - }); - - expect(result).toEqual({ created: true, name: 'User2' }); - expect(identifiers).toHaveProperty('user2', { - type: { - '#/components/schemas/User': { - $ref: '#/components/schemas/User', - name: 'User2', - }, - User2: { - $ref: '#/components/schemas/User', - name: 'User2', - }, - }, - }); - }); -}); diff --git a/packages/openapi-ts/src/generate/file/index.ts b/packages/openapi-ts/src/generate/file/index.ts deleted file mode 100644 index 86cc97edf..000000000 --- a/packages/openapi-ts/src/generate/file/index.ts +++ /dev/null @@ -1,635 +0,0 @@ -import fs from 'node:fs'; -import path from 'node:path'; - -import ts from 'typescript'; - -import type { IR } from '../../ir/types'; -import { getUniqueComponentName } from '../../openApi/shared/transforms/utils'; -import { ensureValidIdentifier } from '../../openApi/shared/utils/identifier'; -import { tsc } from '../../tsc'; -import { type ImportExportItemObject, tsNodeToString } from '../../tsc/utils'; -import type { StringCase } from '../../types/case'; -import { stringCase } from '../../utils/stringCase'; -import { ensureDirSync } from '../utils'; -import type { - FileImportResult, - Identifier, - Identifiers, - Namespace, - NodeInfo, - NodeReference, -} from './types'; -export class GeneratedFile { - private _case: StringCase | undefined; - /** - * Should the exports from this file be re-exported in the index barrel file? - */ - private _exportFromIndex: boolean; - private _headers: Array = []; - private _id: string; - private _imports = new Map>(); - private _items: Array = []; - private _name: string; - private _path: string; - - /** @deprecated use `names` and `nodes` */ - public identifiers: Identifiers = {}; - - /** - * Map of node IDs. This can be used to obtain actual node names. Keys are - * node IDs which can be any string, values are names. Values are kept in - * sync with `nodes`. - * - * @example - * ```json - * { - * "#/my-id": "final_name", - * "anyId": "name" - * } - * ``` - */ - private names: Record = {}; - /** - * Another approach for named nodes, with proper support for renaming. Keys - * are node IDs and values are an array of references for given ID. - */ - private nodeReferences: Record> = {}; - /** - * Text value from node is kept in sync with `names`. - * - * @deprecated - * @example - * ```js - * { - * "#/my-id": { - * "node": TypeReferenceNode - * }, - * "anyId": { - * "node": TypeReferenceNode - * } - * } - * ``` - */ - // TODO: nodes can be possibly replaced with `nodeReferences`, i.e. keep - // the name `nodes` and rewrite their functionality - private nodes: Record = {}; - - /** - * Path relative to the client output root. - */ - // TODO: parser - add relative path property for quick access, currently - // everything is resolved into an absolute path with cwd - // public relativePath: string; - - public constructor({ - case: _case, - dir, - exportFromIndex = false, - header = true, - id, - name, - }: { - case?: StringCase; - dir: string; - /** - * Should the exports from this file be re-exported in the index barrel file? - */ - exportFromIndex?: boolean; - header?: boolean; - /** - * Unique file ID. Used to generate correct relative paths to the file. - * This should be refactored later as it's basically the file name unless - * nested inside another folder. - */ - id: string; - name: string; - }) { - this._case = _case; - this._exportFromIndex = exportFromIndex; - this._id = id; - this._name = this._setName(name); - this._path = path.resolve(dir, this._name); - - if (header) { - this._headers.push( - '// This file is auto-generated by @hey-api/openapi-ts', - ); - } - } - - public add(...nodes: Array) { - this._items = this._items.concat(nodes); - } - - /** - * Adds a reference node for a name. This can be used later to rename - * identifiers. - */ - public addNodeReference( - id: string, - node: Pick, 'factory'>, - ): T { - if (!this.nodeReferences[id]) { - this.nodeReferences[id] = []; - } - const result = node.factory(this.names[id] ?? ''); - this.nodeReferences[id].push({ - factory: node.factory, - node: result as void, - }); - return result; - } - - public get exportFromIndex(): boolean { - return this._exportFromIndex; - } - - /** - * Returns an actual node name. If node doesn't exist throws an error. - * - * @param id Node ID. - * @returns Actual node name. - */ - public getName(id: string): string | undefined { - const name = this.names[id]; - if (!name) { - return; - } - return name; - } - - /** - * Returns a node. If node doesn't exist, creates a blank reference. - * - * @deprecated - * @param id Node ID. - * @returns Information about the node. - */ - public getNode(id: string): NodeInfo { - if (!this.nodes[id]) { - this.nodes[id] = { - node: tsc.typeReferenceNode({ typeName: '' }), - }; - } - return this.nodes[id]!; - } - - public get id(): string { - return this._id; - } - - /** @deprecated use `names` and `nodes` */ - public identifier( - args: Pick< - EnsureUniqueIdentifierData, - '$ref' | 'count' | 'create' | 'nameTransformer' - > & { - case?: StringCase; - namespace: Namespace; - }, - ): Identifier { - return ensureUniqueIdentifier({ - case: args.case ?? this._case, - identifiers: this.identifiers, - ...args, - }); - } - - /** - * Adds an import to the provided module. Handles duplication, returns added - * import. Returns the imported name. If we import an aliased export, `name` - * will be equal to the specified `alias`. - */ - public import< - Name extends string | undefined = string | undefined, - Alias extends string | undefined = undefined, - >({ - module, - ...importedItem - }: ImportExportItemObject & { - module: string; - }): FileImportResult { - if (!importedItem.name) { - return { - name: undefined as any, - }; - } - - let moduleMap = this._imports.get(module); - - if (!moduleMap) { - moduleMap = new Map(); - this._imports.set(module, moduleMap); - } - - const match = moduleMap.get(importedItem.name); - if (match) { - return { - ...match, - name: (match.alias || match.name) as any, - }; - } - - moduleMap.set(importedItem.name, importedItem as any); - return { - ...importedItem, - name: (importedItem.alias || importedItem.name) as any, - }; - } - - public isEmpty() { - return !this._items.length; - } - - public nameWithoutExtension() { - const { name } = splitNameAndExtension(this._name); - return name; - } - - public relativePathToFile({ - context, - id, - }: { - context: IR.Context; - id: string; - }): string { - let filePath = ''; - - // relative file path - if (id.startsWith('.')) { - let configFileParts: Array = []; - // if providing a custom configuration file, relative paths must resolve - // relative to the configuration file. - if (context.config.configFile) { - const cfgParts = context.config.configFile.split('/'); - configFileParts = cfgParts.slice(0, cfgParts.length - 1); - } - filePath = path.resolve(process.cwd(), ...configFileParts, id); - } else { - const file = context.file({ id }); - if (!file) { - throw new Error(`File with id ${id} does not exist`); - } - filePath = file._path; - } - - const thisPathParts = this._path.split(path.sep); - const filePathParts = filePath.split(path.sep); - - let index = -1; - let relativePath = ''; - for (const part of thisPathParts) { - index += 1; - if (filePathParts[index] !== part) { - const pathArray = Array.from({ - length: thisPathParts.length - index, - }).fill(''); - const relativePathToFile = filePathParts.slice(index); - const relativeFolder = relativePathToFile.slice( - 0, - relativePathToFile.length - 1, - ); - if (relativeFolder.length) { - relativeFolder.push(''); - } - relativePath = - (pathArray.join('../') || './') + relativeFolder.join('/'); - break; - } - } - - const fileName = filePathParts[filePathParts.length - 1]!; - // TODO: parser - cache responses - return `${relativePath}${splitNameAndExtension(fileName).name}`; - } - - public remove(options?: Parameters[1]) { - fs.rmSync(this._path, options); - } - - /** - * Removes last node form the stack. Works as undo. - * - * @deprecated - */ - public removeNode_LEGACY() { - this._items = this._items.slice(0, this._items.length - 1); - } - - private _setName(fileName: string) { - if (fileName.includes('index')) { - return fileName; - } - - const { extension, name } = splitNameAndExtension(fileName); - return [name, 'gen', extension].filter(Boolean).join('.'); - } - - private _toString(separator: string, tsConfig: ts.ParsedCommandLine | null) { - let output: Array = []; - if (this._headers.length) { - output.push(this._headers.join('\n')); - } - - const shouldAppendJs = - tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext; - - const importsStringArray: Array = []; - - for (const [_module, moduleMap] of this._imports.entries()) { - const imports = Array.from(moduleMap.values()); - - let resolvedModule = _module; - if ( - shouldAppendJs && - (resolvedModule.startsWith('./') || resolvedModule.startsWith('../')) - ) { - if (resolvedModule === './client') { - resolvedModule = './client/index.js'; - } else { - resolvedModule = `${resolvedModule}.js`; - } - } - - const node = tsc.namedImportDeclarations({ - imports, - module: resolvedModule, - }); - importsStringArray.push(tsNodeToString({ node })); - } - if (importsStringArray.length) { - output.push(importsStringArray.join('\n')); - } - output = output.concat( - this._items.map((node) => - typeof node === 'string' - ? node - : tsNodeToString({ node, unescape: true }), - ), - ); - return output.join(separator); - } - - /** - * Inserts or updates a node. - * - * @deprecated - * @param id Node ID. - * @param args Information about the node. - * @returns Updated node. - */ - public updateNode( - id: string, - args: Pick & { - name: string; - }, - ): NodeInfo { - // update name - const name = getUniqueComponentName({ - base: ensureValidIdentifier(args.name), - components: Object.values(this.names), - }); - this.names[id] = name; - const node = tsc.typeReferenceNode({ typeName: name }); - // update node - if (!this.nodes[id]) { - this.nodes[id] = { node }; - } else { - Object.assign(this.nodes[id].node, node); - } - if (args.exported !== undefined) { - this.nodes[id].exported = args.exported; - } - return this.nodes[id]; - } - - /** - * Updates collected reference nodes for a name with the latest value. - * - * @param id Node ID. - * @param name Updated name for the nodes. - * @returns noop - */ - public updateNodeReferences(id: string, name: string): void { - if (!this.nodeReferences[id]) { - return; - } - const finalName = getUniqueComponentName({ - base: ensureValidIdentifier(name), - components: Object.values(this.names), - }); - this.names[id] = finalName; - for (const node of this.nodeReferences[id]) { - const nextNode = node.factory(finalName); - Object.assign(node.node as unknown as object, nextNode); - } - } - - public write(separator = '\n', tsConfig: ts.ParsedCommandLine | null = null) { - if (this.isEmpty()) { - this.remove({ force: true }); - return; - } - - let dir = this._path; - if (typeof this._path === 'string') { - const parts = this._path.split(path.sep); - dir = parts.slice(0, parts.length - 1).join(path.sep); - } - ensureDirSync(dir); - fs.writeFileSync(this._path, this._toString(separator, tsConfig)); - } -} - -export const parseRef = ( - $ref: string, -): { - /** - * Extracted name from `$ref`, equal to the last part or property name. - */ - name: string; - /** - * List of properties extracted from `$ref`, if any. - */ - properties: ReadonlyArray; - /** - * `$ref` without properties if they're included in `$ref`, otherwise - * `ref` is equal to `$ref`. - */ - ref: string; -} => { - let ref = $ref; - const properties: string[] = []; - - const parts = ref.split('/'); - let name = parts[parts.length - 1] || ''; - - let propIndex = parts.indexOf('properties'); - - if (propIndex !== -1) { - ref = parts.slice(0, propIndex).join('/'); - name = parts[propIndex - 1] || ''; - - while (propIndex + 1 < parts.length) { - const prop = parts[propIndex + 1]; - if (!prop) { - throw new Error(`Invalid $ref: ${$ref}`); - } - properties.push(prop); - propIndex += 2; - } - } - - return { - name, - properties, - ref, - }; -}; - -const transformName = ( - name: string, - transformer: ((name: string) => string) | string, - _case?: StringCase, -): string => { - if (typeof transformer === 'function') { - return transformer(name); - } - - const separator = _case === 'preserve' ? '' : '-'; - return transformer.replace('{{name}}', `${separator}${name}${separator}`); -}; - -export interface EnsureUniqueIdentifierData { - $ref: string; - case: StringCase | undefined; - count?: number; - create?: boolean; - identifiers: Identifiers; - /** - * Transforms name obtained from `$ref` before it's passed to `stringCase()`. - */ - nameTransformer?: ((name: string) => string) | string; - namespace: Namespace; -} - -const ensureUniqueIdentifier = ({ - $ref, - case: _case, - count = 1, - create = false, - identifiers, - nameTransformer, - namespace, -}: EnsureUniqueIdentifierData): Identifier => { - const { name, properties, ref } = parseRef($ref); - - if (!name) { - return { - created: false, - name: '', - }; - } - - let nameWithCasingAndTransformer = stringCase({ - case: _case, - value: nameTransformer ? transformName(name, nameTransformer, _case) : name, - }); - if (count > 1) { - nameWithCasingAndTransformer = `${nameWithCasingAndTransformer}${count}`; - } - const lowercaseName = nameWithCasingAndTransformer.toLocaleLowerCase(); - if (!identifiers[lowercaseName]) { - identifiers[lowercaseName] = {}; - } - const identifier = identifiers[lowercaseName]; - - // Enum declarations can only merge with namespace or other enum - // declarations, so we need to ensure we don't mix them up. - if ( - (namespace === 'enum' && (identifier.type || identifier.value)) || - (namespace !== 'enum' && identifier.enum) - ) { - return ensureUniqueIdentifier({ - $ref: ref, - case: _case, - count: count + 1, - create, - identifiers, - nameTransformer, - namespace, - }); - } - - if (!identifier[namespace]) { - identifier[namespace] = {}; - } - const id = identifier[namespace]; - - const refValue = id[ref]; - if (refValue) { - let name = refValue.name; - if (properties.length) { - name += properties.map((property) => `['${property}']`).join(''); - } - return { - created: false, - name: name as string, - }; - } - - let nameValue = id[nameWithCasingAndTransformer]; - if (nameValue) { - if (nameValue.$ref === ref) { - return { - created: false, - name: nameValue.name, - }; - } - - return ensureUniqueIdentifier({ - $ref: ref, - case: _case, - count: count + 1, - create, - identifiers, - nameTransformer, - namespace, - }); - } - - if (!create) { - delete identifier[namespace]; - return { - created: false, - name: '', - }; - } - - nameValue = { - $ref: ref, - name: ensureValidIdentifier(nameWithCasingAndTransformer), - }; - id[nameWithCasingAndTransformer] = nameValue; - id[nameValue.$ref] = nameValue; - - return { - created: true, - name: nameValue.name, - }; -}; - -export const splitNameAndExtension = (fileName: string) => { - const match = fileName.match(/\.[0-9a-z]+$/i); - const extension = match ? match[0].slice(1) : ''; - const name = fileName.slice( - 0, - fileName.length - (extension ? extension.length + 1 : 0), - ); - return { extension, name }; -}; - -export const _test = { - ensureUniqueIdentifier, - parseRef, -}; diff --git a/packages/openapi-ts/src/generate/file/types.d.ts b/packages/openapi-ts/src/generate/file/types.d.ts deleted file mode 100644 index d45928737..000000000 --- a/packages/openapi-ts/src/generate/file/types.d.ts +++ /dev/null @@ -1,91 +0,0 @@ -import type ts from 'typescript'; - -export interface Identifier { - /** - * Did this function add a new property to the file's `identifiers` map? - */ - created: boolean; - /** - * The resolved identifier name. False means the identifier has been blacklisted. - */ - name: string | false; -} - -type NamespaceEntry = Pick & { - /** - * Ref to the type in OpenAPI specification. - */ - $ref: string; -}; - -export type Identifiers = Record< - string, - { - /** - * TypeScript enum only namespace. - * - * @example - * ```ts - * export enum Foo = { - * FOO = 'foo' - * } - * ``` - */ - enum?: Record; - /** - * Type namespace. Types, interfaces, and type aliases exist here. - * - * @example - * ```ts - * export type Foo = string; - * ``` - */ - type?: Record; - /** - * Value namespace. Variables, functions, classes, and constants exist here. - * - * @example - * ```js - * export const foo = ''; - * ``` - */ - value?: Record; - } ->; - -export type Namespace = keyof Identifiers[keyof Identifiers]; - -export type FileImportResult< - Name extends string | undefined = string | undefined, - Alias extends string | undefined = undefined, -> = { - asType?: boolean; - name: Alias extends string ? Alias : Name; -}; - -export type NodeInfo = { - /** - * Is this node exported from the file? - * - * @default false - */ - exported?: boolean; - /** - * Reference to the node object. - */ - node: ts.TypeReferenceNode; -}; - -export type NodeReference = { - /** - * Factory function that creates the node reference. - * - * @param name Identifier name. - * @returns Reference to the node object. - */ - factory: (name: string) => T; - /** - * Reference to the node object. - */ - node: T; -}; diff --git a/packages/openapi-ts/src/generate/renderer.ts b/packages/openapi-ts/src/generate/renderer.ts index 818a96d9f..212d69ae0 100644 --- a/packages/openapi-ts/src/generate/renderer.ts +++ b/packages/openapi-ts/src/generate/renderer.ts @@ -1,26 +1,35 @@ import type { - CodegenFile, + ICodegenBiMap, ICodegenFile, ICodegenImport, ICodegenMeta, - ICodegenOutput, ICodegenRenderer, } from '@hey-api/codegen-core'; +import { replaceWrappedIds } from '@hey-api/codegen-core'; import ts from 'typescript'; +import { ensureValidIdentifier } from '../openApi/shared/utils/identifier'; import { tsc } from '../tsc'; import { tsNodeToString } from '../tsc/utils'; export class TypeScriptRenderer implements ICodegenRenderer { id = 'typescript'; - render(file: CodegenFile, meta?: ICodegenMeta): ICodegenOutput { - const extension = file.meta.extension ?? ''; - return { - content: this.renderFile(file, meta), - meta: file.meta, - path: `${file.path}${extension}`, - }; + private ensureValidName(name: string): string { + return ensureValidIdentifier(name); + } + + private getUniqueName( + base: string, + names: ICodegenBiMap, + ): string { + let index = 2; + let name = base; + while (names.hasValue(name)) { + name = `${base}${index}`; + index += 1; + } + return name; } private groupByKey( @@ -46,25 +55,27 @@ export class TypeScriptRenderer implements ICodegenRenderer { return grouped; } - private renderFile(file: ICodegenFile, meta?: ICodegenMeta): string { - if (!file.hasContent()) { - return ''; + private renderBody(file: ICodegenFile): string { + const results: Array = []; + for (const symbol of file.symbols) { + if (!symbol.value) continue; + if (typeof symbol.value === 'string') { + results.push(symbol.value); + } else if (symbol.value instanceof Array) { + symbol.value.forEach((node) => { + results.push(`${tsNodeToString({ node, unescape: true })}\n`); + }); + } else { + results.push( + `${tsNodeToString({ node: symbol.value as any, unescape: true })}\n`, + ); + } } - const result = [ - this.renderHeaders(), - this.renderImports(file, meta), - this.renderSymbols(file), - this.renderExports(file, meta), - ] - .filter(Boolean) - .join('\n'); - return result.endsWith('\n') ? result : `${result}\n`; - } - - private renderHeaders(): string { - return ['// This file is auto-generated by @hey-api/openapi-ts', ''].join( - '\n', + let body = results.join('\n'); + body = replaceWrappedIds(body, (symbolId) => + this.replacerFn({ file, headless: false, scope: 'file', symbolId }), ); + return body; } private renderExports(file: ICodegenFile, meta?: ICodegenMeta): string { @@ -100,7 +111,7 @@ export class TypeScriptRenderer implements ICodegenRenderer { for (const value of group) { for (const name of value.names ?? []) { const alias = value.aliases?.[name]; - const spec = + const specifier = alias && alias !== name ? ts.factory.createExportSpecifier( false, @@ -112,7 +123,7 @@ export class TypeScriptRenderer implements ICodegenRenderer { undefined, tsc.identifier({ text: name }), ); - namedSpecifiers.push(spec); + namedSpecifiers.push(specifier); } } @@ -129,7 +140,28 @@ export class TypeScriptRenderer implements ICodegenRenderer { statements.push(''); } - return statements.join('\n'); + let exports = statements.join('\n'); + exports = replaceWrappedIds(exports, (symbolId) => + this.replacerFn({ file, headless: false, scope: 'file', symbolId }), + ); + return exports; + } + + renderHeader(file: ICodegenFile, meta?: ICodegenMeta): string { + if (!file.hasContent()) { + return ''; + } + const result = [this.renderHeaders(), this.renderImports(file, meta)] + .filter(Boolean) + .join('\n'); + // extra line between headers and symbols + return result.endsWith('\n') ? `${result}\n` : `${result}\n\n`; + } + + private renderHeaders(): string { + return ['// This file is auto-generated by @hey-api/openapi-ts', ''].join( + '\n', + ); } private renderImports(file: ICodegenFile, meta?: ICodegenMeta): string { @@ -139,51 +171,86 @@ export class TypeScriptRenderer implements ICodegenRenderer { for (const [from, group] of grouped.entries()) { const specifiers: Array = []; let defaultImport: ts.Identifier | undefined; - let namespaceImport: ts.NamespaceImport | undefined; + let namespaceImport: string | undefined; let isTypeOnly = false; for (const value of group) { if (value.defaultImport) { - defaultImport = ts.factory.createIdentifier(value.defaultImport); + defaultImport = tsc.identifier({ text: value.defaultImport }); if (value.typeDefaultImport) { isTypeOnly = true; } } if (typeof value.namespaceImport === 'string') { - namespaceImport = ts.factory.createNamespaceImport( - tsc.identifier({ text: value.namespaceImport }), + namespaceImport = replaceWrappedIds( + value.namespaceImport, + (symbolId) => this.replacerFn({ file, symbolId }), ); if (value.typeNamespaceImport) { isTypeOnly = true; } } - for (const name of value.names ?? []) { - const alias = value.aliases?.[name]; - const id = tsc.identifier({ text: name }); - const spec = - alias && alias !== name - ? ts.factory.createImportSpecifier( - false, - id, - tsc.identifier({ text: alias }), - ) - : ts.factory.createImportSpecifier(false, undefined, id); - if (value.typeNames?.includes(name)) { + if (value.names && value.names.length > 0) { + if ( + !isTypeOnly && + value.names.every((name) => value.typeNames?.includes(name)) + ) { isTypeOnly = true; } - specifiers.push(spec); + + for (const name of value.names) { + const alias = value.aliases?.[name]; + let finalName = name; + let finalAlias: string | undefined; + if (alias && alias !== finalName) { + finalAlias = finalName; + finalName = alias; + } + finalName = replaceWrappedIds(finalName, (symbolId) => { + const name = this.replacerFn({ file, symbolId }); + const sourceFile = file.project.getFileBySymbolId(symbolId); + const sourceName = sourceFile + ? sourceFile.resolvedNames.get(symbolId) + : undefined; + if (sourceName && sourceName !== name) { + // handle only simple imports for now + if (!finalAlias) { + finalAlias = sourceName; + } + } + return name; + }); + if (finalAlias) { + finalAlias = replaceWrappedIds(finalAlias, (symbolId) => + this.replacerFn({ file, symbolId }), + ); + // remove redundant alias + if (finalAlias === finalName) { + finalAlias = undefined; + } + } + const specifier = ts.factory.createImportSpecifier( + isTypeOnly ? false : (value.typeNames?.includes(name) ?? false), + finalAlias ? tsc.identifier({ text: finalAlias }) : undefined, + tsc.identifier({ text: finalName }), + ); + specifiers.push(specifier); + } } } const importClause = ts.factory.createImportClause( isTypeOnly, defaultImport, - namespaceImport ?? - (specifiers.length + namespaceImport + ? ts.factory.createNamespaceImport( + tsc.identifier({ text: namespaceImport }), + ) + : specifiers.length ? ts.factory.createNamedImports(specifiers) - : undefined), + : undefined, ); const node = ts.factory.createImportDeclaration( @@ -201,16 +268,39 @@ export class TypeScriptRenderer implements ICodegenRenderer { return statements.join('\n'); } - private renderSymbols(file: ICodegenFile): string { - const results: Array = []; - for (const symbol of file.symbols) { - if (!symbol.value) continue; - if (typeof symbol.value === 'string') { - results.push(symbol.value); - } else { - results.push(`${tsNodeToString({ node: symbol.value as any })}\n`); - } + renderSymbols(file: ICodegenFile, meta?: ICodegenMeta): string { + if (!file.hasContent()) { + return ''; + } + const result = [this.renderBody(file), this.renderExports(file, meta)] + .filter(Boolean) + .join('\n'); + return result.endsWith('\n') ? result : `${result}\n`; + } + + replacerFn({ + file, + headless = true, + scope = 'project', + symbolId, + }: { + file: ICodegenFile; + headless?: boolean; + scope?: 'file' | 'project'; + symbolId: number; + }): string | undefined { + const cached = file.resolvedNames.get(symbolId); + if (cached) return cached; + const symbol = + scope === 'file' + ? file.getSymbolById(symbolId) + : file.project.getSymbolById(symbolId); + if (!symbol || (!headless && symbol.value === undefined)) return; + let name = this.ensureValidName(symbol.name); + if (file.resolvedNames.hasValue(name)) { + name = this.getUniqueName(name, file.resolvedNames); } - return results.join('\n'); + file.resolvedNames.set(symbolId, name); + return name; } } diff --git a/packages/openapi-ts/src/ir/context.ts b/packages/openapi-ts/src/ir/context.ts index 36c521510..c9b1ce7ee 100644 --- a/packages/openapi-ts/src/ir/context.ts +++ b/packages/openapi-ts/src/ir/context.ts @@ -89,7 +89,6 @@ export class IRContext = any> { ...outputParts.slice(0, outputParts.length - 1), ); const createdFile = new GeneratedFile({ - case: file.case, dir: outputDir, exportFromIndex: file.exportFromIndex, id: file.id, diff --git a/packages/openapi-ts/src/ir/types.d.ts b/packages/openapi-ts/src/ir/types.d.ts index e80add5f7..435e04ba1 100644 --- a/packages/openapi-ts/src/ir/types.d.ts +++ b/packages/openapi-ts/src/ir/types.d.ts @@ -3,7 +3,6 @@ import type { SecuritySchemeObject, ServerObject, } from '../openApi/3.1.x/types/spec'; -import type { StringCase } from '../types/case'; import type { IRContext } from './context'; import type { IRMediaType } from './mediaType'; @@ -26,10 +25,6 @@ interface IRComponentsObject { } interface IRContextFile { - /** - * Define casing for identifiers in this file. - */ - case?: StringCase; /** * Should the exports from this file be re-exported in the index barrel file? */ diff --git a/packages/openapi-ts/src/plugins/@angular/common/api.ts b/packages/openapi-ts/src/plugins/@angular/common/api.ts new file mode 100644 index 000000000..78581f485 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@angular/common/api.ts @@ -0,0 +1,36 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | 'class' + | 'httpRequest' + | 'httpResource' + | 'HttpRequest' + | 'inject' + | 'Injectable'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `class`: raw string entry from path + * - `httpRequest`: `operation.id` string + * - `httpResource`: never + * - `HttpRequest`: never + * - `inject`: never + * - `Injectable`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@angular/common'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@angular/common/config.ts b/packages/openapi-ts/src/plugins/@angular/common/config.ts index 3eee37dc1..2e4d5be80 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/config.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/config.ts @@ -1,8 +1,12 @@ import { definePluginConfig } from '../../shared/utils/config'; +import { Api } from './api'; import { handler } from './plugin'; import type { AngularCommonPlugin } from './types'; export const defaultConfig: AngularCommonPlugin['Config'] = { + api: new Api({ + name: '@angular/common', + }), config: { exportFromIndex: false, }, diff --git a/packages/openapi-ts/src/plugins/@angular/common/constants.ts b/packages/openapi-ts/src/plugins/@angular/common/constants.ts deleted file mode 100644 index 1d421d0a1..000000000 --- a/packages/openapi-ts/src/plugins/@angular/common/constants.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const REQUEST_APIS_SUFFIX = '/http/requests'; -export const RESOURCE_APIS_SUFFIX = '/http/resources'; diff --git a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts index 7ea9b2487..30bc7baad 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts @@ -1,19 +1,17 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import type { GeneratedFile } from '../../../generate/file'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { stringCase } from '../../../utils/stringCase'; -import { clientId } from '../../@hey-api/client-core/utils'; -import { sdkId } from '../../@hey-api/sdk/constants'; +import { getClientPlugin } from '../../@hey-api/client-core/utils'; import { operationClasses } from '../../@hey-api/sdk/operation'; -import { typesId } from '../../@hey-api/typescript/ref'; import { createOperationComment, isOperationOptionsRequired, } from '../../shared/utils/operation'; -import { REQUEST_APIS_SUFFIX } from './constants'; import type { AngularCommonPlugin } from './types'; interface AngularRequestClassEntry { @@ -24,19 +22,20 @@ interface AngularRequestClassEntry { root: boolean; } +const pathSuffix = '/http/requests'; + const generateAngularClassRequests = ({ - file, plugin, }: { - file: GeneratedFile; plugin: AngularCommonPlugin['Instance']; }) => { + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + const requestClasses = new Map(); const generatedClasses = new Set(); - const sdkPlugin = plugin.getPlugin('@hey-api/sdk')!; + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - // Iterate through operations to build class structure plugin.forEach('operation', ({ operation }) => { const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, @@ -75,18 +74,14 @@ const generateAngularClassRequests = ({ const currentClass = requestClasses.get(currentClassName)!; - // Generate the request method name with "Request" suffix const requestMethodName = plugin.config.httpRequests.methodNameBuilder(operation); - // Avoid duplicate methods if (currentClass.methods.has(requestMethodName)) { return; } - // Generate Angular request method const methodNode = generateAngularRequestMethod({ - file, isRequiredOptions, methodName: requestMethodName, operation, @@ -106,13 +101,11 @@ const generateAngularClassRequests = ({ } }); - // Generate classes const generateClass = (currentClass: AngularRequestClassEntry) => { if (generatedClasses.has(currentClass.className)) { return; } - // Handle child classes if (currentClass.classes.size) { for (const childClassName of currentClass.classes) { const childClass = requestClasses.get(childClassName)!; @@ -141,18 +134,16 @@ const generateAngularClassRequests = ({ } } - const node = tsc.classDeclaration({ - decorator: currentClass.root - ? { - args: [ - { - providedIn: 'root', - }, - ], - name: 'Injectable', - } - : undefined, - exportClass: currentClass.root, + const symbolInjectable = f + .ensureSymbol({ + selector: plugin.api.getSelector('Injectable'), + }) + .update({ name: 'Injectable' }); + f.addImport({ + from: '@angular/core', + names: [symbolInjectable.placeholder], + }); + const symbolClass = f.addSymbol({ name: buildName({ config: { case: 'preserve', @@ -160,10 +151,21 @@ const generateAngularClassRequests = ({ }, name: currentClass.className, }), + selector: plugin.api.getSelector('class', currentClass.className), + }); + const node = tsc.classDeclaration({ + decorator: currentClass.root + ? { + args: [{ providedIn: 'root' }], + name: symbolInjectable.placeholder, + } + : undefined, + exportClass: currentClass.root, + name: symbolClass.placeholder, nodes: currentClass.nodes, }); + symbolClass.update({ value: node }); - file.add(node); generatedClasses.add(currentClass.className); }; @@ -173,52 +175,55 @@ const generateAngularClassRequests = ({ }; const generateAngularFunctionRequests = ({ - file, plugin, }: { - file: GeneratedFile; plugin: AngularCommonPlugin['Instance']; }) => { + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + plugin.forEach('operation', ({ operation }) => { const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, }); - // Generate function name with "Request" suffix - const functionName = - plugin.config.httpRequests.methodNameBuilder(operation); - + const symbol = f.addSymbol({ + name: plugin.config.httpRequests.methodNameBuilder(operation), + selector: plugin.api.getSelector('httpRequest', operation.id), + }); const node = generateAngularRequestFunction({ - file, - functionName, isRequiredOptions, operation, plugin, + symbol, }); - - file.add(node); + symbol.update({ value: node }); }); }; const generateRequestCallExpression = ({ - file, operation, plugin, }: { - file: GeneratedFile; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - // TODO: client might not be always defined - const heyApiClient = file.import({ - alias: '_heyApiClient', - module: file.relativePathToFile({ - context: plugin.context, - id: clientId, - }), - name: 'client', - }); + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + + let symbolClient: ICodegenSymbolOut | undefined; + const client = getClientPlugin(plugin.context.config); + if (client.api && 'getSelector' in client.api) { + symbolClient = plugin.gen.selectSymbolFirst( + // @ts-expect-error + client.api.getSelector('client'), + ); + if (symbolClient) { + f.addImport({ + from: symbolClient.file, + names: [symbolClient.placeholder], + }); + } + } const optionsClient = tsc.propertyAccessExpression({ expression: tsc.identifier({ text: 'options' }), @@ -226,13 +231,20 @@ const generateRequestCallExpression = ({ name: 'client', }); + let clientExpression: ts.Expression; + if (symbolClient) { + clientExpression = tsc.binaryExpression({ + left: optionsClient, + operator: '??', + right: symbolClient.placeholder, + }); + } else { + clientExpression = optionsClient; + } + return tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: tsc.binaryExpression({ - left: optionsClient, - operator: '??', - right: tsc.identifier({ text: heyApiClient.name }), - }), + expression: clientExpression, name: 'requestOptions', }), parameters: [ @@ -262,29 +274,50 @@ const generateRequestCallExpression = ({ }; const generateAngularRequestMethod = ({ - file, isRequiredOptions, methodName, operation, plugin, }: { - file: GeneratedFile; isRequiredOptions: boolean; methodName: string; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - // Import operation data type - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const dataType = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'data' }), - ), + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + + const symbolHttpRequest = f + .ensureSymbol({ + selector: plugin.api.getSelector('HttpRequest'), + }) + .update({ name: 'HttpRequest' }); + f.addImport({ + from: '@angular/common/http', + typeNames: [symbolHttpRequest.placeholder], }); + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + f.addImport({ + from: symbolOptions.file, + typeNames: [symbolOptions.placeholder], + }); + + const symbolDataType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('data', operation.id), + ); + if (symbolDataType) { + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], + }); + } + const dataType = symbolDataType?.placeholder || 'unknown'; + return tsc.methodDeclaration({ accessLevel: 'public', comment: createOperationComment({ operation }), @@ -293,14 +326,13 @@ const generateAngularRequestMethod = ({ { isRequired: isRequiredOptions, name: 'options', - type: `Options<${dataType.name || 'unknown'}, ThrowOnError>`, + type: `${symbolOptions.placeholder}<${dataType}, ThrowOnError>`, }, ], - returnType: 'HttpRequest', + returnType: `${symbolHttpRequest.placeholder}`, statements: [ tsc.returnStatement({ expression: generateRequestCallExpression({ - file, operation, plugin, }), @@ -317,28 +349,50 @@ const generateAngularRequestMethod = ({ }; const generateAngularRequestFunction = ({ - file, - functionName, isRequiredOptions, operation, plugin, + symbol, }: { - file: GeneratedFile; - functionName: string; isRequiredOptions: boolean; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; + symbol: ICodegenSymbolOut; }) => { - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const dataType = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'data' }), - ), + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + + const symbolHttpRequest = f + .ensureSymbol({ + selector: plugin.api.getSelector('HttpRequest'), + }) + .update({ name: 'HttpRequest' }); + f.addImport({ + from: '@angular/common/http', + typeNames: [symbolHttpRequest.placeholder], + }); + + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + f.addImport({ + from: symbolOptions.file, + typeNames: [symbolOptions.placeholder], }); + const symbolDataType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('data', operation.id), + ); + if (symbolDataType) { + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], + }); + } + const dataType = symbolDataType?.placeholder || 'unknown'; + return tsc.constVariable({ comment: createOperationComment({ operation }), exportConst: true, @@ -347,14 +401,13 @@ const generateAngularRequestFunction = ({ { isRequired: isRequiredOptions, name: 'options', - type: `Options<${dataType.name || 'unknown'}, ThrowOnError>`, + type: `${symbolOptions.placeholder}<${dataType}, ThrowOnError>`, }, ], - returnType: 'HttpRequest', + returnType: `${symbolHttpRequest.placeholder}`, statements: [ tsc.returnStatement({ expression: generateRequestCallExpression({ - file, operation, plugin, }), @@ -368,41 +421,22 @@ const generateAngularRequestFunction = ({ }, ], }), - name: functionName, + name: symbol.placeholder, }); }; export const createHttpRequests: AngularCommonPlugin['Handler'] = ({ plugin, }) => { - const file = plugin.createFile({ - id: `${plugin.name}${REQUEST_APIS_SUFFIX}`, - path: `${plugin.output}${REQUEST_APIS_SUFFIX}`, - }); - - if (plugin.config.httpRequests.asClass) { - file.import({ - module: '@angular/core', - name: 'Injectable', - }); - } - - file.import({ - module: '@angular/common/http', - name: 'HttpRequest', - }); - - file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: sdkId, - }), - name: 'Options', + plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); if (plugin.config.httpRequests.asClass) { - generateAngularClassRequests({ file, plugin }); + generateAngularClassRequests({ plugin }); } else { - generateAngularFunctionRequests({ file, plugin }); + generateAngularFunctionRequests({ plugin }); } }; diff --git a/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts b/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts index 132c62569..7da78742e 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts @@ -1,18 +1,16 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import type { GeneratedFile } from '../../../generate/file'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { stringCase } from '../../../utils/stringCase'; -import { sdkId } from '../../@hey-api/sdk/constants'; import { operationClasses } from '../../@hey-api/sdk/operation'; -import { typesId } from '../../@hey-api/typescript/ref'; import { createOperationComment, isOperationOptionsRequired, } from '../../shared/utils/operation'; -import { REQUEST_APIS_SUFFIX, RESOURCE_APIS_SUFFIX } from './constants'; import type { AngularCommonPlugin } from './types'; interface AngularServiceClassEntry { @@ -23,19 +21,20 @@ interface AngularServiceClassEntry { root: boolean; } +const pathSuffix = '/http/resources'; + const generateAngularClassServices = ({ - file, plugin, }: { - file: GeneratedFile; plugin: AngularCommonPlugin['Instance']; }) => { + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + const serviceClasses = new Map(); const generatedClasses = new Set(); - const sdkPlugin = plugin.getPlugin('@hey-api/sdk')!; + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - // Iterate through operations to build class structure plugin.forEach('operation', ({ operation }) => { const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, @@ -74,18 +73,14 @@ const generateAngularClassServices = ({ const currentClass = serviceClasses.get(currentClassName)!; - // Generate the resource method name const resourceMethodName = plugin.config.httpResources.methodNameBuilder(operation); - // Avoid duplicate methods if (currentClass.methods.has(resourceMethodName)) { return; } - // Generate Angular resource method const methodNode = generateAngularResourceMethod({ - file, isRequiredOptions, methodName: resourceMethodName, operation, @@ -105,13 +100,11 @@ const generateAngularClassServices = ({ } }); - // Generate classes const generateClass = (currentClass: AngularServiceClassEntry) => { if (generatedClasses.has(currentClass.className)) { return; } - // Handle child classes if (currentClass.classes.size) { for (const childClassName of currentClass.classes) { const childClass = serviceClasses.get(childClassName)!; @@ -140,18 +133,16 @@ const generateAngularClassServices = ({ } } - const node = tsc.classDeclaration({ - decorator: currentClass.root - ? { - args: [ - { - providedIn: 'root', - }, - ], - name: 'Injectable', - } - : undefined, - exportClass: currentClass.root, + const symbolInjectable = f + .ensureSymbol({ + selector: plugin.api.getSelector('Injectable'), + }) + .update({ name: 'Injectable' }); + f.addImport({ + from: '@angular/core', + names: [symbolInjectable.placeholder], + }); + const symbolClass = f.addSymbol({ name: buildName({ config: { case: 'preserve', @@ -159,10 +150,20 @@ const generateAngularClassServices = ({ }, name: currentClass.className, }), + }); + const node = tsc.classDeclaration({ + decorator: currentClass.root + ? { + args: [{ providedIn: 'root' }], + name: symbolInjectable.placeholder, + } + : undefined, + exportClass: currentClass.root, + name: symbolClass.placeholder, nodes: currentClass.nodes, }); + symbolClass.update({ value: node }); - file.add(node); generatedClasses.add(currentClass.className); }; @@ -172,47 +173,44 @@ const generateAngularClassServices = ({ }; const generateAngularFunctionServices = ({ - file, plugin, }: { - file: GeneratedFile; plugin: AngularCommonPlugin['Instance']; }) => { + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + plugin.forEach('operation', ({ operation }) => { const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, }); + const symbol = f.addSymbol({ + name: plugin.config.httpResources.methodNameBuilder(operation), + }); const node = generateAngularResourceFunction({ - file, - functionName: plugin.config.httpResources.methodNameBuilder(operation), isRequiredOptions, operation, plugin, + symbol, }); - - file.add(node); + symbol.update({ value: node }); }); }; const generateResourceCallExpression = ({ - file, isRequiredOptions, operation, plugin, - responseTypeName, }: { - file: GeneratedFile; isRequiredOptions: boolean; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; - responseTypeName: string; }) => { - const sdkPlugin = plugin.getPlugin('@hey-api/sdk')!; + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - // Check if httpRequest is configured to use classes - const useRequestClasses = plugin.config.httpRequests.asClass; let requestFunctionCall; // Create the options call expression based on whether options are required @@ -230,7 +228,7 @@ const generateResourceCallExpression = ({ }), }); - if (useRequestClasses) { + if (plugin.config.httpRequests.asClass) { // For class-based request methods, use inject and class hierarchy const classes = operationClasses({ context: plugin.context, @@ -242,18 +240,27 @@ const generateResourceCallExpression = ({ if (firstEntry) { // Import the root class from HTTP requests const rootClassName = firstEntry.path[0]!; - const requestClassName = buildName({ - config: { - case: 'preserve', - name: plugin.config.httpRequests.classNameBuilder, - }, - name: rootClassName, + const symbolClass = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('class', rootClassName), + ); + f.addImport({ + from: symbolClass.file, + names: [symbolClass.placeholder], }); // Build the method access path using inject + const symbolInject = f + .ensureSymbol({ + selector: plugin.api.getSelector('inject'), + }) + .update({ name: 'inject' }); + f.addImport({ + from: '@angular/core', + names: [symbolInject.placeholder], + }); let methodAccess: ts.Expression = tsc.callExpression({ - functionName: 'inject', - parameters: [tsc.identifier({ text: requestClassName })], + functionName: symbolInject.placeholder, + parameters: [tsc.identifier({ text: symbolClass.placeholder })], }); // Navigate through the class hierarchy @@ -284,26 +291,43 @@ const generateResourceCallExpression = ({ }); } } else { - // For function-based request methods, import and call the function directly - const requestFunctionName = - plugin.config.httpRequests.methodNameBuilder(operation); - - const requestImport = file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: `${plugin.name}${REQUEST_APIS_SUFFIX}`, - }), - name: requestFunctionName, + const symbolHttpRequest = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('httpRequest', operation.id), + ); + f.addImport({ + from: symbolHttpRequest.file, + names: [symbolHttpRequest.placeholder], }); - requestFunctionCall = tsc.callExpression({ - functionName: requestImport.name, + functionName: symbolHttpRequest.placeholder, parameters: [optionsCallExpression], }); } + const symbolHttpResource = f + .ensureSymbol({ + selector: plugin.api.getSelector('httpResource'), + }) + .update({ name: 'httpResource' }); + f.addImport({ + from: '@angular/common/http', + names: [symbolHttpResource.placeholder], + }); + + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + const symbolResponseType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('response', operation.id), + ); + if (symbolResponseType) { + f.addImport({ + from: symbolResponseType.file, + typeNames: [symbolResponseType.placeholder], + }); + } + const responseType = symbolResponseType?.placeholder || 'unknown'; + return tsc.callExpression({ - functionName: 'httpResource', + functionName: symbolHttpResource.placeholder, parameters: [ tsc.arrowFunction({ parameters: [], @@ -314,64 +338,63 @@ const generateResourceCallExpression = ({ ], }), ], - types: [tsc.typeNode(responseTypeName)], + types: [tsc.typeNode(responseType)], }); }; const generateAngularResourceMethod = ({ - file, isRequiredOptions, methodName, operation, plugin, }: { - file: GeneratedFile; isRequiredOptions: boolean; methodName: string; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - // Import operation data type - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const dataType = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'data' }), - ), - }); + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - // Import operation response type - const responseType = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'response' }), - ), + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + f.addImport({ + from: symbolOptions.file, + typeNames: [symbolOptions.placeholder], }); + const symbolDataType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('data', operation.id), + ); + if (symbolDataType) { + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], + }); + } + const dataType = symbolDataType?.placeholder || 'unknown'; + return tsc.methodDeclaration({ accessLevel: 'public', comment: createOperationComment({ operation }), - // isStatic: true, name: methodName, parameters: [ { isRequired: isRequiredOptions, name: 'options', - type: `() => Options<${dataType.name || 'unknown'}, ThrowOnError>`, + type: `() => ${symbolOptions.placeholder}<${dataType}, ThrowOnError>`, }, ], returnType: undefined, statements: [ tsc.returnStatement({ expression: generateResourceCallExpression({ - file, isRequiredOptions, operation, plugin, - responseTypeName: responseType.name || 'unknown', }), }), ], @@ -386,37 +409,40 @@ const generateAngularResourceMethod = ({ }; const generateAngularResourceFunction = ({ - file, - functionName, isRequiredOptions, operation, plugin, + symbol, }: { - file: GeneratedFile; - functionName: string; isRequiredOptions: boolean; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; + symbol: ICodegenSymbolOut; }) => { - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const dataType = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'data' }), - ), - }); + const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); + + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - // Import operation response type - const responseType = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'response' }), - ), + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + f.addImport({ + from: symbolOptions.file, + typeNames: [symbolOptions.placeholder], }); + const symbolDataType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('data', operation.id), + ); + if (symbolDataType) { + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], + }); + } + const dataType = symbolDataType?.placeholder || 'unknown'; + return tsc.constVariable({ comment: createOperationComment({ operation }), exportConst: true, @@ -425,17 +451,15 @@ const generateAngularResourceFunction = ({ { isRequired: isRequiredOptions, name: 'options', - type: `() => Options<${dataType.name || 'unknown'}, ThrowOnError>`, + type: `() => ${symbolOptions.placeholder}<${dataType}, ThrowOnError>`, }, ], statements: [ tsc.returnStatement({ expression: generateResourceCallExpression({ - file, isRequiredOptions, operation, plugin, - responseTypeName: responseType.name || 'unknown', }), }), ], @@ -447,48 +471,22 @@ const generateAngularResourceFunction = ({ }, ], }), - name: functionName, + name: symbol.placeholder, }); }; export const createHttpResources: AngularCommonPlugin['Handler'] = ({ plugin, }) => { - const file = plugin.createFile({ - id: `${plugin.name}${RESOURCE_APIS_SUFFIX}`, - path: `${plugin.output}${RESOURCE_APIS_SUFFIX}`, - }); - - if (plugin.config.httpResources.asClass) { - file.import({ - module: '@angular/core', - name: 'Injectable', - }); - } - - if (plugin.config.httpRequests.asClass) { - file.import({ - module: '@angular/core', - name: 'inject', - }); - } - - file.import({ - module: '@angular/common/http', - name: 'httpResource', - }); - - file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: sdkId, - }), - name: 'Options', + plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); if (plugin.config.httpResources.asClass) { - generateAngularClassServices({ file, plugin }); + generateAngularClassServices({ plugin }); } else { - generateAngularFunctionServices({ file, plugin }); + generateAngularFunctionServices({ plugin }); } }; diff --git a/packages/openapi-ts/src/plugins/@angular/common/types.d.ts b/packages/openapi-ts/src/plugins/@angular/common/types.d.ts index 3c9f4ccc4..47830c53f 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/types.d.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/types.d.ts @@ -1,5 +1,6 @@ import type { StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@angular/common'> & { /** @@ -150,4 +151,4 @@ export type Config = Plugin.Name<'@angular/common'> & { output: string; }; -export type AngularCommonPlugin = DefinePlugin; +export type AngularCommonPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts new file mode 100644 index 000000000..163a1bdd9 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts @@ -0,0 +1,25 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/client-angular'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts index 7f1ada3ab..206439156 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts @@ -1,15 +1,19 @@ import { definePluginConfig } from '../../shared/utils/config'; import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; import { clientPluginHandler } from '../client-core/plugin'; +import { Api } from './api'; import type { HeyApiClientAngularPlugin } from './types'; export const defaultConfig: HeyApiClientAngularPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: '@hey-api/client-angular', + }), config: { ...clientDefaultConfig, throwOnError: false, }, - handler: clientPluginHandler as HeyApiClientAngularPlugin['Handler'], + handler: clientPluginHandler, name: '@hey-api/client-angular', }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts index 903df96cb..f00c11617 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts @@ -1,5 +1,6 @@ import type { DefinePlugin, Plugin } from '../../types'; import type { Client } from '../client-core/types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@hey-api/client-angular'> & Client.Config & { @@ -11,4 +12,8 @@ export type UserConfig = Plugin.Name<'@hey-api/client-angular'> & throwOnError?: boolean; }; -export type HeyApiClientAngularPlugin = DefinePlugin; +export type HeyApiClientAngularPlugin = DefinePlugin< + UserConfig, + UserConfig, + IApi +>; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts new file mode 100644 index 000000000..71da134b7 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts @@ -0,0 +1,25 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/client-axios'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts index 2163a49a0..7cc48c700 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts @@ -1,15 +1,19 @@ import { definePluginConfig } from '../../shared/utils/config'; import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; import { clientPluginHandler } from '../client-core/plugin'; +import { Api } from './api'; import type { HeyApiClientAxiosPlugin } from './types'; export const defaultConfig: HeyApiClientAxiosPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: '@hey-api/client-axios', + }), config: { ...clientDefaultConfig, throwOnError: false, }, - handler: clientPluginHandler as HeyApiClientAxiosPlugin['Handler'], + handler: clientPluginHandler, name: '@hey-api/client-axios', }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-axios/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-axios/types.d.ts index c7bfb119b..0d31baa36 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-axios/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-axios/types.d.ts @@ -1,5 +1,6 @@ import type { DefinePlugin, Plugin } from '../../types'; import type { Client } from '../client-core/types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@hey-api/client-axios'> & Client.Config & { @@ -11,4 +12,8 @@ export type UserConfig = Plugin.Name<'@hey-api/client-axios'> & throwOnError?: boolean; }; -export type HeyApiClientAxiosPlugin = DefinePlugin; +export type HeyApiClientAxiosPlugin = DefinePlugin< + UserConfig, + UserConfig, + IApi +>; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts index 889af840a..d88c5ce9f 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts @@ -1,9 +1,10 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; + import { clientModulePath } from '../../../generate/client'; import { tsc } from '../../../tsc'; import { parseUrl } from '../../../utils/url'; -import { typesId } from '../typescript/ref'; import type { PluginHandler } from './types'; -import { clientId, getClientBaseUrlKey } from './utils'; +import { getClientBaseUrlKey } from './utils'; const resolveBaseUrlString = ({ plugin, @@ -27,40 +28,46 @@ const resolveBaseUrlString = ({ return servers[typeof baseUrl === 'number' ? baseUrl : 0]?.url; }; -export const createClient = ({ plugin }: Parameters[0]) => { - const file = plugin.context.file({ id: clientId })!; +export const createClient: PluginHandler = ({ plugin }) => { + const f = plugin.gen.ensureFile(plugin.output); const clientModule = clientModulePath({ config: plugin.context.config, - sourceOutput: file.nameWithoutExtension(), + sourceOutput: f.path, }); - const createClient = file.import({ - module: clientModule, - name: 'createClient', + const symbolCreateClient = f.addSymbol({ name: 'createClient' }); + f.addImport({ + aliases: { + [symbolCreateClient.name]: symbolCreateClient.placeholder, + }, + from: clientModule, + names: [symbolCreateClient.name], }); - const createConfig = file.import({ - module: clientModule, - name: 'createConfig', + const symbolCreateConfig = f.addSymbol({ name: 'createConfig' }); + f.addImport({ + aliases: { + [symbolCreateConfig.name]: symbolCreateConfig.placeholder, + }, + from: clientModule, + names: [symbolCreateConfig.name], }); - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const clientOptions = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ type: 'ClientOptions' }), - ), + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + const symbolClientOptions = plugin.gen.selectSymbolFirstOrThrow( + pluginTypeScript.api.getSelector('ClientOptions'), + ); + f.addImport({ + from: symbolClientOptions.file, + typeNames: [symbolClientOptions.placeholder], }); - const createClientConfig = plugin.config.runtimeConfigPath - ? file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: plugin.config.runtimeConfigPath, - }), - name: 'createClientConfig', - }) - : undefined; + let symbolCreateClientConfig: ICodegenSymbolOut | undefined; + if (plugin.config.runtimeConfigPath) { + symbolCreateClientConfig = f.addSymbol({ name: 'createClientConfig' }); + f.addImport({ + from: f.relativePathToFile({ path: plugin.config.runtimeConfigPath }), + names: [symbolCreateClientConfig.placeholder], + }); + } const defaultValues: Array = []; @@ -94,30 +101,34 @@ export const createClient = ({ plugin }: Parameters[0]) => { const createConfigParameters = [ tsc.callExpression({ - functionName: createConfig.name, + functionName: symbolCreateConfig.placeholder, parameters: defaultValues.length ? [tsc.objectExpression({ obj: defaultValues })] : undefined, - types: clientOptions.name - ? [tsc.typeReferenceNode({ typeName: clientOptions.name })] - : undefined, + types: [ + tsc.typeReferenceNode({ typeName: symbolClientOptions.placeholder }), + ], }), ]; + const symbolClient = f.addSymbol({ + name: 'client', + selector: plugin.api.getSelector('client'), + }); const statement = tsc.constVariable({ exportConst: true, expression: tsc.callExpression({ - functionName: createClient.name, - parameters: createClientConfig + functionName: symbolCreateClient.placeholder, + parameters: symbolCreateClientConfig ? [ tsc.callExpression({ - functionName: createClientConfig.name, + functionName: symbolCreateClientConfig.placeholder, parameters: createConfigParameters, }), ] : createConfigParameters, }), - name: 'client', + name: symbolClient.placeholder, }); - file.add(statement); + symbolClient.update({ value: statement }); }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/createClientConfig.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/createClientConfig.ts index a55355d9b..3e5ffa3ca 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/createClientConfig.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/createClientConfig.ts @@ -1,44 +1,43 @@ import { clientModulePath } from '../../../generate/client'; import { tsc } from '../../../tsc'; -import { clientId } from '../client-core/utils'; -import { typesId } from '../typescript/ref'; import type { PluginHandler } from './types'; export const createClientConfigType = ({ plugin, }: Parameters[0]) => { - const file = plugin.context.file({ id: clientId })!; + const f = plugin.gen.ensureFile(plugin.output); const clientModule = clientModulePath({ config: plugin.context.config, - sourceOutput: file.nameWithoutExtension(), + sourceOutput: f.path, }); - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const clientOptions = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ type: 'ClientOptions' }), - ), + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + const symbolClientOptions = plugin.gen.selectSymbolFirstOrThrow( + pluginTypeScript.api.getSelector('ClientOptions'), + ); + f.addImport({ + from: symbolClientOptions.file, + typeNames: [symbolClientOptions.placeholder], }); - const configType = file.import({ - asType: true, - module: clientModule, - name: 'Config', + const symbolConfig = f.addSymbol({ name: 'Config' }); + const symbolDefaultClientOptions = f.addSymbol({ + name: 'DefaultClientOptions', }); - const defaultClientOptions = file.import({ - alias: 'DefaultClientOptions', - asType: true, - module: clientModule, - name: 'ClientOptions', + f.addImport({ + aliases: { + ClientOptions: symbolDefaultClientOptions.placeholder, + [symbolConfig.name]: symbolConfig.placeholder, + }, + from: clientModule, + typeNames: ['ClientOptions', symbolConfig.name], }); const defaultClientOptionsType = tsc.typeReferenceNode({ - typeName: defaultClientOptions.name, + typeName: symbolDefaultClientOptions.placeholder, }); const tType = tsc.typeReferenceNode({ typeName: 'T' }); + const symbolCreateClientConfig = f.addSymbol({ name: 'CreateClientConfig' }); const typeCreateClientConfig = tsc.typeAliasDeclaration({ comment: [ 'The `createClientConfig()` function will be called on client initialization', @@ -49,7 +48,7 @@ export const createClientConfigType = ({ 'to ensure your client always has the correct values.', ], exportType: true, - name: 'CreateClientConfig', + name: symbolCreateClientConfig.placeholder, type: tsc.functionTypeNode({ parameters: [ tsc.parameterDeclaration({ @@ -61,7 +60,7 @@ export const createClientConfigType = ({ types: [defaultClientOptionsType, tType], }), ], - typeName: configType.name, + typeName: symbolConfig.placeholder, }), }), ], @@ -77,19 +76,18 @@ export const createClientConfigType = ({ ], }), ], - typeName: configType.name, + typeName: symbolConfig.placeholder, }), }), typeParameters: [ { - default: clientOptions.name - ? tsc.typeReferenceNode({ typeName: clientOptions.name }) - : undefined, + default: tsc.typeReferenceNode({ + typeName: symbolClientOptions.placeholder, + }), extends: defaultClientOptionsType, name: 'T', }, ], }); - - file.add(typeCreateClientConfig); + symbolCreateClientConfig.update({ value: typeCreateClientConfig }); }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/plugin.ts index 1f6200abe..7b452df79 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/plugin.ts @@ -1,4 +1,4 @@ -import { clientId } from '../client-core/utils'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import { createClient } from './client'; import { createClientConfigType } from './createClientConfig'; import type { PluginHandler } from './types'; @@ -6,15 +6,17 @@ import type { PluginHandler } from './types'; export const clientPluginHandler = ({ plugin, }: Parameters[0]) => { - plugin.createFile({ - id: clientId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); - createClientConfigType({ - plugin: plugin as any, - }); - createClient({ - plugin: plugin as any, - }); + createClientConfigType({ plugin }); + createClient({ plugin }); + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts index 884d51696..593fdf190 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/types.d.ts @@ -4,12 +4,13 @@ import type { HeyApiClientFetchPlugin } from '../client-fetch'; import type { HeyApiClientNextPlugin } from '../client-next'; import type { HeyApiClientNuxtPlugin } from '../client-nuxt'; -export type PluginHandler = - | HeyApiClientAngularPlugin['Handler'] - | HeyApiClientAxiosPlugin['Handler'] - | HeyApiClientFetchPlugin['Handler'] - | HeyApiClientNextPlugin['Handler'] - | HeyApiClientNuxtPlugin['Handler']; +export interface PluginHandler { + (...args: Parameters): void; + (...args: Parameters): void; + (...args: Parameters): void; + (...args: Parameters): void; + (...args: Parameters): void; +} /** * Public Client API. diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/utils.ts index 1c501ef04..9ad8f1adb 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/utils.ts @@ -1,8 +1,6 @@ import type { Config } from '../../../types/config'; import type { PluginClientNames } from '../../types'; -export const clientId = 'client'; - export const getClientBaseUrlKey = (config: Config) => { const client = getClientPlugin(config); if ( diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts new file mode 100644 index 000000000..3b1233a7b --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts @@ -0,0 +1,25 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/client-fetch'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts index c37410045..e998359d3 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts @@ -1,15 +1,19 @@ import { definePluginConfig } from '../../shared/utils/config'; import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; import { clientPluginHandler } from '../client-core/plugin'; +import { Api } from './api'; import type { HeyApiClientFetchPlugin } from './types'; export const defaultConfig: HeyApiClientFetchPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: '@hey-api/client-fetch', + }), config: { ...clientDefaultConfig, throwOnError: false, }, - handler: clientPluginHandler as HeyApiClientFetchPlugin['Handler'], + handler: clientPluginHandler, name: '@hey-api/client-fetch', }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.d.ts index d9d48234a..89ccfec08 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/types.d.ts @@ -1,5 +1,6 @@ import type { DefinePlugin, Plugin } from '../../types'; import type { Client } from '../client-core/types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@hey-api/client-fetch'> & Client.Config & { @@ -11,4 +12,8 @@ export type UserConfig = Plugin.Name<'@hey-api/client-fetch'> & throwOnError?: boolean; }; -export type HeyApiClientFetchPlugin = DefinePlugin; +export type HeyApiClientFetchPlugin = DefinePlugin< + UserConfig, + UserConfig, + IApi +>; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts new file mode 100644 index 000000000..f4de19160 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts @@ -0,0 +1,25 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/client-next'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts index e54782276..f97faa6ea 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts @@ -1,15 +1,19 @@ import { definePluginConfig } from '../../shared/utils/config'; import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; import { clientPluginHandler } from '../client-core/plugin'; +import { Api } from './api'; import type { HeyApiClientNextPlugin } from './types'; export const defaultConfig: HeyApiClientNextPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: '@hey-api/client-next', + }), config: { ...clientDefaultConfig, throwOnError: false, }, - handler: clientPluginHandler as HeyApiClientNextPlugin['Handler'], + handler: clientPluginHandler, name: '@hey-api/client-next', }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/types.d.ts index 84bcdca46..a4ecee19d 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/types.d.ts @@ -1,5 +1,6 @@ import type { DefinePlugin, Plugin } from '../../types'; import type { Client } from '../client-core/types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@hey-api/client-next'> & Client.Config & { @@ -11,4 +12,4 @@ export type UserConfig = Plugin.Name<'@hey-api/client-next'> & throwOnError?: boolean; }; -export type HeyApiClientNextPlugin = DefinePlugin; +export type HeyApiClientNextPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts new file mode 100644 index 000000000..cc0ed614b --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts @@ -0,0 +1,25 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = 'client'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `client`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/client-nuxt'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts index a8907b95a..3a11f545b 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts @@ -1,12 +1,16 @@ import { definePluginConfig } from '../../shared/utils/config'; import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; import { clientPluginHandler } from '../client-core/plugin'; +import { Api } from './api'; import type { HeyApiClientNuxtPlugin } from './types'; export const defaultConfig: HeyApiClientNuxtPlugin['Config'] = { ...clientDefaultMeta, + api: new Api({ + name: '@hey-api/client-nuxt', + }), config: clientDefaultConfig, - handler: clientPluginHandler as HeyApiClientNuxtPlugin['Handler'], + handler: clientPluginHandler, name: '@hey-api/client-nuxt', }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.d.ts index d38ccbe22..1c45f5704 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/types.d.ts @@ -1,6 +1,7 @@ import type { DefinePlugin, Plugin } from '../../types'; import type { Client } from '../client-core/types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@hey-api/client-nuxt'> & Client.Config; -export type HeyApiClientNuxtPlugin = DefinePlugin; +export type HeyApiClientNuxtPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts b/packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts new file mode 100644 index 000000000..ad718d3b4 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts @@ -0,0 +1,25 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = 'ref'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `ref`: `$ref` JSON pointer + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/schemas'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts b/packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts index 232c8b247..d01e5ee1e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts @@ -1,9 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; +import { Api } from './api'; import { handler } from './plugin'; import { handlerLegacy } from './plugin-legacy'; import type { HeyApiSchemasPlugin } from './types'; export const defaultConfig: HeyApiSchemasPlugin['Config'] = { + api: new Api({ + name: '@hey-api/schemas', + }), config: { exportFromIndex: false, nameBuilder: (name) => `${name}Schema`, diff --git a/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts index 654846042..e5d455774 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts @@ -1,3 +1,4 @@ +import { TypeScriptRenderer } from '../../../generate/renderer'; import type { IR } from '../../../ir/types'; import type { OpenApiV2_0_XTypes } from '../../../openApi/2.0.x'; import type { OpenApiV3_0_XTypes } from '../../../openApi/3.0.x'; @@ -7,8 +8,6 @@ import type { OpenApi } from '../../../openApi/types'; import { tsc } from '../../../tsc'; import type { HeyApiSchemasPlugin } from './types'; -const schemasId = 'schemas'; - const stripSchema = ({ plugin, schema, @@ -368,6 +367,11 @@ const schemasV2_0_X = ({ for (const name in context.spec.definitions) { const schema = context.spec.definitions[name]!; + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f.ensureSymbol({ + name: schemaName({ name, plugin, schema }), + selector: plugin.api.getSelector('ref', name), + }); const obj = schemaToJsonSchemaDraft_04({ context, plugin, @@ -377,9 +381,9 @@ const schemasV2_0_X = ({ assertion: 'const', exportConst: true, expression: tsc.objectExpression({ obj }), - name: schemaName({ name, plugin, schema }), + name: symbol.placeholder, }); - context.file({ id: schemasId })!.add(statement); + symbol.update({ value: statement }); } }; @@ -396,6 +400,11 @@ const schemasV3_0_X = ({ for (const name in context.spec.components.schemas) { const schema = context.spec.components.schemas[name]!; + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f.ensureSymbol({ + name: schemaName({ name, plugin, schema }), + selector: plugin.api.getSelector('ref', name), + }); const obj = schemaToJsonSchemaDraft_05({ context, plugin, @@ -405,9 +414,9 @@ const schemasV3_0_X = ({ assertion: 'const', exportConst: true, expression: tsc.objectExpression({ obj }), - name: schemaName({ name, plugin, schema }), + name: symbol.placeholder, }); - context.file({ id: schemasId })!.add(statement); + symbol.update({ value: statement }); } }; @@ -424,6 +433,11 @@ const schemasV3_1_X = ({ for (const name in context.spec.components.schemas) { const schema = context.spec.components.schemas[name]!; + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f.ensureSymbol({ + name: schemaName({ name, plugin, schema }), + selector: plugin.api.getSelector('ref', name), + }); const obj = schemaToJsonSchema2020_12({ context, plugin, @@ -433,16 +447,17 @@ const schemasV3_1_X = ({ assertion: 'const', exportConst: true, expression: tsc.objectExpression({ obj }), - name: schemaName({ name, plugin, schema }), + name: symbol.placeholder, }); - context.file({ id: schemasId })!.add(statement); + symbol.update({ value: statement }); } }; export const handler: HeyApiSchemasPlugin['Handler'] = ({ plugin }) => { - plugin.createFile({ - id: schemasId, - path: plugin.output, + plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); if ('swagger' in plugin.context.spec) { diff --git a/packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts index c1c74c116..d094bb67f 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/types.d.ts @@ -3,6 +3,7 @@ import type { OpenApiV2_0_XTypes } from '../../../openApi/2.0.x'; import type { OpenApiV3_0_XTypes } from '../../../openApi/3.0.x'; import type { OpenApiV3_1_XTypes } from '../../../openApi/3.1.x'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@hey-api/schemas'> & { /** @@ -47,4 +48,4 @@ export type UserConfig = Plugin.Name<'@hey-api/schemas'> & { type?: 'form' | 'json'; }; -export type HeyApiSchemasPlugin = DefinePlugin; +export type HeyApiSchemasPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts new file mode 100644 index 000000000..9ef79067c --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts @@ -0,0 +1,38 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | 'buildClientParams' + | 'class' + | 'Client' + | 'formDataBodySerializer' + | 'function' + | 'Options' + | 'urlSearchParamsBodySerializer'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `buildClientParams`: never + * - `class`: current class name + * - `Client`: never + * - `formDataBodySerializer`: never + * - `function`: `operation.id` string + * - `Options`: never + * - `urlSearchParamsBodySerializer`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/sdk'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts index a5f59f09a..9396cb2c0 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts @@ -1,9 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; +import { Api } from './api'; import { handler } from './plugin'; import { handlerLegacy } from './plugin-legacy'; import type { HeyApiSdkPlugin } from './types'; export const defaultConfig: HeyApiSdkPlugin['Config'] = { + api: new Api({ + name: '@hey-api/sdk', + }), config: { asClass: false, auth: true, diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/constants.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/constants.ts index e9da8dc83..5b5567560 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/constants.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/constants.ts @@ -1,5 +1,3 @@ export const nuxtTypeComposable = 'TComposable'; export const nuxtTypeDefault = 'DefaultT'; export const nuxtTypeResponse = 'ResT'; - -export const sdkId = 'sdk'; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts index 684684eb1..d4a2eb5a8 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/operation.ts @@ -1,7 +1,7 @@ +import type { ICodegenFile, ICodegenSymbolOut } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import { clientApi, clientModulePath } from '../../../generate/client'; -import type { GeneratedFile } from '../../../generate/file'; +import { clientModulePath } from '../../../generate/client'; import { statusCodeToGroup } from '../../../ir/operation'; import type { IR } from '../../../ir/types'; import { sanitizeNamespaceIdentifier } from '../../../openApi'; @@ -12,15 +12,10 @@ import { reservedJavaScriptKeywordsRegExp } from '../../../utils/regexp'; import { stringCase } from '../../../utils/stringCase'; import { transformClassName } from '../../../utils/transform'; import type { Field, Fields } from '../client-core/bundle/params'; -import { clientId, getClientPlugin } from '../client-core/utils'; -import { - operationTransformerIrRef, - transformersId, -} from '../transformers/plugin'; -import { typesId } from '../typescript/ref'; +import { getClientPlugin } from '../client-core/utils'; import type { PluginState } from '../typescript/types'; import { operationAuth } from './auth'; -import { nuxtTypeComposable, nuxtTypeDefault, sdkId } from './constants'; +import { nuxtTypeComposable, nuxtTypeDefault } from './constants'; import type { HeyApiSdkPlugin } from './types'; import { createRequestValidator, createResponseValidator } from './validator'; @@ -158,7 +153,7 @@ export const operationOptionsType = ({ plugin, throwOnError, }: { - file: GeneratedFile; + file: ICodegenFile; operation: IR.OperationObject; plugin: HeyApiSdkPlugin['Instance']; throwOnError?: string; @@ -166,36 +161,44 @@ export const operationOptionsType = ({ const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const dataImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'data' }), - ), - }); - const optionsName = clientApi.Options.name; + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - if (isNuxtClient) { - const responseImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ - operation, - type: isNuxtClient ? 'response' : 'responses', - }), - ), + const symbolDataType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('data', operation.id), + ); + if (symbolDataType) { + file.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], }); - return `${optionsName}<${nuxtTypeComposable}, ${dataImport.name || 'unknown'}, ${responseImport.name || 'unknown'}, ${nuxtTypeDefault}>`; + } + const dataType = symbolDataType?.placeholder || 'unknown'; + + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('Options'), + ); + + if (isNuxtClient) { + const symbolResponseType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('response', operation.id), + ); + if (symbolResponseType) { + file.addImport({ + from: symbolResponseType.file, + typeNames: [symbolResponseType.placeholder], + }); + } + const responseType = symbolResponseType?.placeholder || 'unknown'; + return `${symbolOptions.placeholder}<${nuxtTypeComposable}, ${dataType}, ${responseType}, ${nuxtTypeDefault}>`; } // TODO: refactor this to be more generic, works for now if (throwOnError) { - return `${optionsName}<${dataImport.name || 'unknown'}, ${throwOnError}>`; + return `${symbolOptions.placeholder}<${dataType}, ${throwOnError}>`; } - return dataImport.name ? `${optionsName}<${dataImport.name}>` : optionsName; + return symbolDataType + ? `${symbolOptions.placeholder}<${symbolDataType.placeholder}>` + : symbolOptions.placeholder; }; type OperationParameters = { @@ -210,7 +213,7 @@ export const operationParameters = ({ operation, plugin, }: { - file: GeneratedFile; + file: ICodegenFile; isRequiredOptions: boolean; operation: IR.OperationObject; plugin: HeyApiSdkPlugin['Instance']; @@ -221,7 +224,7 @@ export const operationParameters = ({ parameters: [], }; - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); const typescriptState: PluginState = { usedTypeIDs: new Set(), }; @@ -229,8 +232,6 @@ export const operationParameters = ({ const isNuxtClient = client.name === '@hey-api/client-nuxt'; if (plugin.config.params_EXPERIMENTAL === 'experiment') { - const fileTypeScript = plugin.context.file({ id: typesId })!; - if (operation.parameters?.path) { for (const key in operation.parameters.path) { const parameter = operation.parameters.path[key]!; @@ -245,14 +246,10 @@ export const operationParameters = ({ isRequired: parameter.required, name, type: pluginTypeScript.api.schemaToType({ - onRef: (id) => { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: fileTypeScript.getName(id), + onRef: (symbol) => { + file.addImport({ + from: symbol.file, + typeNames: [symbol.placeholder], }); }, plugin: pluginTypeScript, @@ -277,14 +274,10 @@ export const operationParameters = ({ isRequired: parameter.required, name, type: pluginTypeScript.api.schemaToType({ - onRef: (id) => { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: fileTypeScript.getName(id), + onRef: (symbol) => { + file.addImport({ + from: symbol.file, + typeNames: [symbol.placeholder], }); }, plugin: pluginTypeScript, @@ -304,14 +297,10 @@ export const operationParameters = ({ isRequired: operation.body.required, name, type: pluginTypeScript.api.schemaToType({ - onRef: (id) => { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: fileTypeScript.getName(id), + onRef: (symbol) => { + file.addImport({ + from: symbol.file, + typeNames: [symbol.placeholder], }); }, plugin: pluginTypeScript, @@ -404,34 +393,40 @@ export const operationStatements = ({ operation: IR.OperationObject; plugin: HeyApiSdkPlugin['Instance']; }): Array => { - const file = plugin.context.file({ id: sdkId })!; - const sdkOutput = file.nameWithoutExtension(); + const f = plugin.gen.ensureFile(plugin.output); const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const responseImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ - operation, - type: isNuxtClient ? 'response' : 'responses', - }), + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + + const symbolResponseType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector( + isNuxtClient ? 'response' : 'responses', + operation.id, ), - }); - const errorImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ - operation, - type: isNuxtClient ? 'error' : 'errors', - }), + ); + if (symbolResponseType) { + f.addImport({ + from: symbolResponseType.file, + typeNames: [symbolResponseType.placeholder], + }); + } + const responseType = symbolResponseType?.placeholder || 'unknown'; + + const symbolErrorType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector( + isNuxtClient ? 'error' : 'errors', + operation.id, ), - }); + ); + if (symbolErrorType) { + f.addImport({ + from: symbolErrorType.file, + typeNames: [symbolErrorType.placeholder], + }); + } + const errorType = symbolErrorType?.placeholder || 'unknown'; // TODO: transform parameters // const query = { @@ -449,19 +444,23 @@ export const operationStatements = ({ // } // } - const requestOptions: ObjectValue[] = []; + const requestOptions: Array = []; if (operation.body) { switch (operation.body.type) { case 'form-data': { - const imported = file.import({ - module: clientModulePath({ + const symbol = f.ensureSymbol({ + name: 'formDataBodySerializer', + selector: plugin.api.getSelector('formDataBodySerializer'), + }); + f.addImport({ + from: clientModulePath({ config: plugin.context.config, - sourceOutput: sdkOutput, + sourceOutput: f.path, }), - name: 'formDataBodySerializer', + names: [symbol.name], }); - requestOptions.push({ spread: imported.name }); + requestOptions.push({ spread: symbol.placeholder }); break; } case 'json': @@ -476,14 +475,18 @@ export const operationStatements = ({ }); break; case 'url-search-params': { - const imported = file.import({ - module: clientModulePath({ + const symbol = f.ensureSymbol({ + name: 'urlSearchParamsBodySerializer', + selector: plugin.api.getSelector('urlSearchParamsBodySerializer'), + }); + f.addImport({ + from: clientModulePath({ config: plugin.context.config, - sourceOutput: sdkOutput, + sourceOutput: f.path, }), - name: 'urlSearchParamsBodySerializer', + names: [symbol.name], }); - requestOptions.push({ spread: imported.name }); + requestOptions.push({ spread: symbol.placeholder }); break; } } @@ -532,25 +535,20 @@ export const operationStatements = ({ } if (plugin.config.transformer === '@hey-api/transformers') { - const identifierTransformer = plugin.context - .file({ id: transformersId })! - .identifier({ - $ref: operationTransformerIrRef({ id: operation.id, type: 'response' }), - namespace: 'value', - }); - - if (identifierTransformer.name) { - file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: transformersId, - }), - name: identifierTransformer.name, + const pluginTransformers = plugin.getPluginOrThrow( + plugin.config.transformer, + ); + const symbolResponseTransformer = plugin.gen.selectSymbolFirst( + pluginTransformers.api.getSelector('response', operation.id), + ); + if (symbolResponseTransformer?.value) { + f.addImport({ + from: symbolResponseTransformer.file, + names: [symbolResponseTransformer.placeholder], }); - requestOptions.push({ key: 'responseTransformer', - value: identifierTransformer.name, + value: symbolResponseTransformer.placeholder, }); } } @@ -644,17 +642,24 @@ export const operationStatements = ({ } config.push(tsc.objectExpression({ obj })); } - const imported = file.import({ - module: clientModulePath({ + const symbol = f.ensureSymbol({ + name: 'buildClientParams', + selector: plugin.api.getSelector('buildClientParams'), + }); + f.addImport({ + aliases: { + buildClientParams: symbol.placeholder, + }, + from: clientModulePath({ config: plugin.context.config, - sourceOutput: sdkOutput, + sourceOutput: f.path, }), - name: 'buildClientParams', + names: ['buildClientParams'], }); statements.push( tsc.constVariable({ expression: tsc.callExpression({ - functionName: imported.name, + functionName: symbol.placeholder, parameters: [ tsc.arrayLiteralExpression({ elements: args }), tsc.arrayLiteralExpression({ elements: config }), @@ -703,19 +708,19 @@ export const operationStatements = ({ } } - const responseType = responseImport.name || 'unknown'; - const errorType = errorImport.name || 'unknown'; - - const heyApiClient = plugin.config.client - ? file.import({ - alias: '_heyApiClient', - module: file.relativePathToFile({ - context: plugin.context, - id: clientId, - }), - name: 'client', - }) - : undefined; + let symbolClient: ICodegenSymbolOut | undefined; + if (plugin.config.client && client.api && 'getSelector' in client.api) { + symbolClient = plugin.gen.selectSymbolFirst( + // @ts-expect-error + client.api.getSelector('client'), + ); + if (symbolClient) { + f.addImport({ + from: symbolClient.file, + names: [symbolClient.placeholder], + }); + } + } const optionsClient = tsc.propertyAccessExpression({ expression: tsc.identifier({ text: 'options' }), @@ -724,7 +729,6 @@ export const operationStatements = ({ }); let clientExpression: ts.Expression; - if (plugin.config.instance) { clientExpression = tsc.binaryExpression({ left: optionsClient, @@ -734,11 +738,11 @@ export const operationStatements = ({ name: '_client', }), }); - } else if (heyApiClient?.name) { + } else if (symbolClient) { clientExpression = tsc.binaryExpression({ left: optionsClient, operator: '??', - right: tsc.identifier({ text: heyApiClient.name }), + right: symbolClient.placeholder, }); } else { clientExpression = optionsClient; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin-legacy.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin-legacy.ts index 45a2216d5..3a8c30c3c 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin-legacy.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin-legacy.ts @@ -1,6 +1,6 @@ import type ts from 'typescript'; -import { clientApi, clientModulePath } from '../../../generate/client'; +import { clientModulePath } from '../../../generate/client'; import { GeneratedFile } from '../../../generate/file'; import type { IR } from '../../../ir/types'; import { isOperationParameterRequired } from '../../../openApi'; @@ -96,7 +96,7 @@ export const operationOptionsLegacyParserType = ({ importedType?: string | false; throwOnError?: string; }) => { - const optionsName = clientApi.OptionsLegacyParser.name; + const optionsName = 'OptionsLegacyParser'; // TODO: refactor this to be more generic, works for now if (throwOnError) { return `${optionsName}<${importedType || 'unknown'}, ${throwOnError}>`; @@ -825,8 +825,9 @@ export const handlerLegacy: HeyApiSdkPlugin['LegacyHandler'] = ({ name: 'createConfig', }); files.sdk.import({ - ...clientApi.OptionsLegacyParser, + asType: true, module: clientModulePath({ config, sourceOutput: sdkOutput }), + name: 'OptionsLegacyParser', }); } else { const clientPlugin = getClientPlugin(config); diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts index 5466af08c..ea7d38ddb 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts @@ -1,6 +1,8 @@ -import ts from 'typescript'; +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type ts from 'typescript'; -import { clientApi, clientModulePath } from '../../../generate/client'; +import { clientModulePath } from '../../../generate/client'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import { tsc } from '../../../tsc'; import { stringCase } from '../../../utils/stringCase'; import { @@ -8,8 +10,7 @@ import { isOperationOptionsRequired, } from '../../shared/utils/operation'; import { getClientPlugin } from '../client-core/utils'; -import { typesId } from '../typescript/ref'; -import { nuxtTypeComposable, nuxtTypeDefault, sdkId } from './constants'; +import { nuxtTypeComposable, nuxtTypeDefault } from './constants'; import { operationClasses, operationParameters, @@ -38,14 +39,28 @@ const createClientClassNodes = ({ }), }); + const f = plugin.gen.ensureFile(plugin.output); + + const symbolClient = f.ensureSymbol({ + selector: plugin.api.getSelector('Client'), + }); + const client = getClientPlugin(plugin.context.config); + let symClient: ICodegenSymbolOut | undefined; + if (client.api && 'getSelector' in client.api) { + symClient = plugin.gen.selectSymbolFirst( + // @ts-expect-error + client.api.getSelector('client'), + ); + } + return [ tsc.propertyDeclaration({ - initializer: plugin.config.client - ? tsc.identifier({ text: '_heyApiClient' }) + initializer: symClient + ? tsc.identifier({ text: symClient.placeholder }) : undefined, modifier: 'protected', name: '_client', - type: ts.factory.createTypeReferenceNode('Client'), + type: tsc.typeReferenceNode({ typeName: symbolClient.placeholder }), }), // @ts-expect-error tsc.identifier({ text: '\n' }), @@ -60,7 +75,7 @@ const createClientClassNodes = ({ { isRequired: !plugin.config.client, name: 'client', - type: 'Client', + type: symbolClient.placeholder, }, ], useLegacyResolution: false, @@ -91,9 +106,13 @@ interface SdkClassEntry { */ className: string; /** - * Child classes located inside this class. + * Symbol IDs for child classes located inside this class. */ - classes: Set; + classes: Set; + /** + * Symbol ID for the class. + */ + id: number; /** * Track unique added method nodes. */ @@ -116,12 +135,12 @@ const generateClassSdk = ({ const client = getClientPlugin(plugin.context.config); const isAngularClient = client.name === '@hey-api/client-angular'; const isNuxtClient = client.name === '@hey-api/client-nuxt'; - const file = plugin.context.file({ id: sdkId })!; - const sdkClasses = new Map(); + const f = plugin.gen.ensureFile(plugin.output); + const sdkClasses = new Map(); /** * Track unique added classes. */ - const generatedClasses = new Set(); + const generatedClasses = new Set(); const clientClassNodes = plugin.config.instance ? createClientClassNodes({ plugin }) @@ -132,17 +151,19 @@ const generateClassSdk = ({ context: plugin.context, operation, }); - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const responseImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: isNuxtClient - ? fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'response' }), - ) - : undefined, - }); + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + let symbolResponse: ICodegenSymbolOut | undefined; + if (isNuxtClient) { + symbolResponse = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('response', operation.id), + ); + if (symbolResponse) { + f.addImport({ + from: symbolResponse.file, + typeNames: [symbolResponse.placeholder], + }); + } + } const classes = operationClasses({ context: plugin.context, @@ -152,10 +173,15 @@ const generateClassSdk = ({ for (const entry of classes.values()) { entry.path.forEach((currentClassName, index) => { - if (!sdkClasses.has(currentClassName)) { - sdkClasses.set(currentClassName, { - className: currentClassName, + const symbolCurrentClass = f.ensureSymbol({ + name: currentClassName, + selector: plugin.api.getSelector('class', currentClassName), + }); + if (!sdkClasses.has(symbolCurrentClass.id)) { + sdkClasses.set(symbolCurrentClass.id, { + className: symbolCurrentClass.name, classes: new Set(), + id: symbolCurrentClass.id, methods: new Set(), nodes: [], root: !index, @@ -163,10 +189,18 @@ const generateClassSdk = ({ } const parentClassName = entry.path[index - 1]; - if (parentClassName && parentClassName !== currentClassName) { - const parentClass = sdkClasses.get(parentClassName)!; - parentClass.classes.add(currentClassName); - sdkClasses.set(parentClassName, parentClass); + if (parentClassName) { + const symbolParentClass = f.ensureSymbol({ + name: parentClassName, + selector: plugin.api.getSelector('class', parentClassName), + }); + if ( + symbolParentClass.placeholder !== symbolCurrentClass.placeholder + ) { + const parentClass = sdkClasses.get(symbolParentClass.id)!; + parentClass.classes.add(symbolCurrentClass.id); + sdkClasses.set(symbolParentClass.id, parentClass); + } } const isLast = entry.path.length === index + 1; @@ -175,7 +209,7 @@ const generateClassSdk = ({ return; } - const currentClass = sdkClasses.get(currentClassName)!; + const currentClass = sdkClasses.get(symbolCurrentClass.id)!; // avoid duplicate methods if (currentClass.methods.has(entry.methodName)) { @@ -183,7 +217,7 @@ const generateClassSdk = ({ } const opParameters = operationParameters({ - file, + file: f, isRequiredOptions, operation, plugin, @@ -210,14 +244,14 @@ const generateClassSdk = ({ name: nuxtTypeComposable, }, { - default: responseImport.name + default: symbolResponse ? tsc.typeReferenceNode({ - typeName: responseImport.name, + typeName: symbolResponse.placeholder, }) : tsc.typeNode('undefined'), - extends: responseImport.name + extends: symbolResponse ? tsc.typeReferenceNode({ - typeName: responseImport.name, + typeName: symbolResponse.placeholder, }) : undefined, name: nuxtTypeDefault, @@ -247,13 +281,15 @@ const generateClassSdk = ({ currentClass.methods.add(entry.methodName); - sdkClasses.set(currentClassName, currentClass); + sdkClasses.set(symbolCurrentClass.id, currentClass); }); } }); + const symbolHeyApiClient = f.addSymbol({ name: '_HeyApiClient' }); + const generateClass = (currentClass: SdkClassEntry) => { - if (generatedClasses.has(currentClass.className)) { + if (generatedClasses.has(currentClass.id)) { return; } @@ -283,10 +319,12 @@ const generateClassSdk = ({ ] : [], expression: tsc.identifier({ - text: childClass.className, + text: f.getSymbolById(childClass.id)!.placeholder, }), }) - : tsc.identifier({ text: childClass.className }), + : tsc.identifier({ + text: f.getSymbolById(childClass.id)!.placeholder, + }), modifier: plugin.config.instance ? undefined : 'static', name: stringCase({ case: 'camelCase', @@ -297,6 +335,10 @@ const generateClassSdk = ({ } } + const symbol = f.ensureSymbol({ + name: currentClass.className, + selector: plugin.api.getSelector('class', currentClass.className), + }); const node = tsc.classDeclaration({ decorator: currentClass.root && isAngularClient @@ -310,21 +352,23 @@ const generateClassSdk = ({ } : undefined, exportClass: currentClass.root, - extendedClasses: plugin.config.instance ? ['_HeyApiClient'] : undefined, - name: currentClass.className, + extendedClasses: plugin.config.instance + ? [symbolHeyApiClient.placeholder] + : undefined, + name: symbol.placeholder, nodes: currentClass.nodes, }); - file.add(node); - generatedClasses.add(currentClass.className); + symbol.update({ value: node }); + generatedClasses.add(symbol.id); }; if (clientClassNodes.length) { const node = tsc.classDeclaration({ exportClass: false, - name: '_HeyApiClient', + name: symbolHeyApiClient.placeholder, nodes: clientClassNodes, }); - file.add(node); + symbolHeyApiClient.update({ value: node }); } for (const sdkClass of sdkClasses.values()) { @@ -339,26 +383,28 @@ const generateFlatSdk = ({ }) => { const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; - const file = plugin.context.file({ id: sdkId })!; + const f = plugin.gen.ensureFile(plugin.output); plugin.forEach('operation', ({ operation }) => { const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, }); - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const responseImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: isNuxtClient - ? fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'response' }), - ) - : undefined, - }); + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + let symbolResponse: ICodegenSymbolOut | undefined; + if (isNuxtClient) { + symbolResponse = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('response', operation.id), + ); + if (symbolResponse) { + f.addImport({ + from: symbolResponse.file, + typeNames: [symbolResponse.placeholder], + }); + } + } const opParameters = operationParameters({ - file, + file: f, isRequiredOptions, operation, plugin, @@ -369,6 +415,15 @@ const generateFlatSdk = ({ operation, plugin, }); + const symbol = f.addSymbol({ + name: serviceFunctionIdentifier({ + config: plugin.context.config, + handleIllegal: true, + id: operation.id, + operation, + }), + selector: plugin.api.getSelector('function', operation.id), + }); const node = tsc.constVariable({ comment: createOperationComment({ operation }), exportConst: true, @@ -384,14 +439,14 @@ const generateFlatSdk = ({ name: nuxtTypeComposable, }, { - default: responseImport.name + default: symbolResponse ? tsc.typeReferenceNode({ - typeName: responseImport.name, + typeName: symbolResponse.placeholder, }) : tsc.typeNode('undefined'), - extends: responseImport.name + extends: symbolResponse ? tsc.typeReferenceNode({ - typeName: responseImport.name, + typeName: symbolResponse.placeholder, }) : undefined, name: nuxtTypeDefault, @@ -408,57 +463,54 @@ const generateFlatSdk = ({ }, ], }), - name: serviceFunctionIdentifier({ - config: plugin.context.config, - handleIllegal: true, - id: operation.id, - operation, - }), + name: symbol.placeholder, }); - file.add(node); + symbol.update({ value: node }); }); }; export const handler: HeyApiSdkPlugin['Handler'] = ({ plugin }) => { - const file = plugin.createFile({ - id: sdkId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); // import required packages and core files const clientModule = clientModulePath({ config: plugin.context.config, - sourceOutput: file.nameWithoutExtension(), + sourceOutput: f.path, }); - const clientOptions = file.import({ - ...clientApi.Options, - alias: 'ClientOptions', - module: clientModule, + const symbolClientOptions = f.addSymbol({ name: 'ClientOptions' }); + f.addImport({ + aliases: { + Options: symbolClientOptions.placeholder, + }, + from: clientModule, + typeNames: ['Options'], }); const client = getClientPlugin(plugin.context.config); const isAngularClient = client.name === '@hey-api/client-angular'; const isNuxtClient = client.name === '@hey-api/client-nuxt'; if (isNuxtClient) { - file.import({ - asType: true, - module: clientModule, - name: 'Composable', - }); + f.addImport({ from: clientModule, typeNames: ['Composable'] }); } if (isAngularClient && plugin.config.asClass) { - file.import({ - module: '@angular/core', - name: 'Injectable', - }); + f.addImport({ from: '@angular/core', names: ['Injectable'] }); } - createTypeOptions({ clientOptions, plugin }); + createTypeOptions({ plugin, symbolClientOptions }); if (plugin.config.asClass) { generateClassSdk({ plugin }); } else { generateFlatSdk({ plugin }); } + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/typeOptions.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/typeOptions.ts index 50be94f18..2890f2d01 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/typeOptions.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/typeOptions.ts @@ -1,39 +1,42 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; + import { clientModulePath } from '../../../generate/client'; -import type { FileImportResult } from '../../../generate/file/types'; import { tsc } from '../../../tsc'; import { getClientPlugin } from '../client-core/utils'; -import { nuxtTypeDefault, nuxtTypeResponse, sdkId } from './constants'; +import { nuxtTypeDefault, nuxtTypeResponse } from './constants'; import type { HeyApiSdkPlugin } from './types'; export const createTypeOptions = ({ - clientOptions, plugin, + symbolClientOptions, }: { - clientOptions: FileImportResult; plugin: HeyApiSdkPlugin['Instance']; + symbolClientOptions: ICodegenSymbolOut; }) => { - const file = plugin.context.file({ id: sdkId })!; + const f = plugin.gen.ensureFile(plugin.output); const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; const clientModule = clientModulePath({ config: plugin.context.config, - sourceOutput: file.nameWithoutExtension(), - }); - const tDataShape = file.import({ - asType: true, - module: clientModule, - name: 'TDataShape', + sourceOutput: f.path, }); - const clientType = file.import({ - asType: true, - module: clientModule, + const symbolTDataShape = f.addSymbol({ name: 'TDataShape' }); + const symbolClient = f.ensureSymbol({ name: 'Client', + selector: plugin.api.getSelector('Client'), + }); + f.addImport({ + from: clientModule, + typeNames: [symbolClient.name, symbolTDataShape.name], }); + const symbolOptions = f + .ensureSymbol({ selector: plugin.api.getSelector('Options') }) + .update({ name: 'Options' }); const typeOptions = tsc.typeAliasDeclaration({ exportType: true, - name: 'Options', + name: symbolOptions.placeholder, type: tsc.typeIntersectionNode({ types: [ tsc.typeReferenceNode({ @@ -48,7 +51,7 @@ export const createTypeOptions = ({ tsc.typeReferenceNode({ typeName: 'TData' }), tsc.typeReferenceNode({ typeName: 'ThrowOnError' }), ], - typeName: clientOptions.name, + typeName: symbolClientOptions.placeholder, }), tsc.typeInterfaceNode({ properties: [ @@ -60,7 +63,9 @@ export const createTypeOptions = ({ ], isRequired: !plugin.config.client, name: 'client', - type: tsc.typeReferenceNode({ typeName: clientType.name }), + type: tsc.typeReferenceNode({ + typeName: symbolClient.placeholder, + }), }, { comment: [ @@ -90,10 +95,10 @@ export const createTypeOptions = ({ }), tsc.typeParameterDeclaration({ constraint: tsc.typeReferenceNode({ - typeName: tDataShape.name, + typeName: symbolTDataShape.placeholder, }), defaultType: tsc.typeReferenceNode({ - typeName: tDataShape.name, + typeName: symbolTDataShape.placeholder, }), name: 'TData', }), @@ -109,10 +114,10 @@ export const createTypeOptions = ({ : [ tsc.typeParameterDeclaration({ constraint: tsc.typeReferenceNode({ - typeName: tDataShape.name, + typeName: symbolTDataShape.placeholder, }), defaultType: tsc.typeReferenceNode({ - typeName: tDataShape.name, + typeName: symbolTDataShape.placeholder, }), name: 'TData', }), @@ -123,6 +128,5 @@ export const createTypeOptions = ({ }), ], }); - - file.add(typeOptions); + symbolOptions.update({ value: typeOptions }); }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts index 1a76275c2..d83fd1b55 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts @@ -7,6 +7,7 @@ import type { PluginClientNames, PluginValidatorNames, } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@hey-api/sdk'> & { /** @@ -337,4 +338,4 @@ export type Config = Plugin.Name<'@hey-api/sdk'> & { response: 'body' | 'response'; }; -export type HeyApiSdkPlugin = DefinePlugin; +export type HeyApiSdkPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/validator.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/validator.ts index cd115251f..8cfd735ea 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/validator.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/validator.ts @@ -1,51 +1,43 @@ +import type ts from 'typescript'; + import type { IR } from '../../../ir/types'; -import { sdkId } from './constants'; import type { HeyApiSdkPlugin } from './types'; +interface ValidatorProps { + operation: IR.OperationObject; + plugin: HeyApiSdkPlugin['Instance']; +} + export const createRequestValidator = ({ operation, plugin, -}: { - operation: IR.OperationObject; - plugin: HeyApiSdkPlugin['Instance']; -}) => { - if (!plugin.config.validator.request) { - return; - } - - const pluginValidator = plugin.getPlugin(plugin.config.validator.request); - if (!pluginValidator || !pluginValidator.api.createRequestValidator) { - return; - } - - return pluginValidator.api.createRequestValidator({ - file: plugin.context.file({ id: sdkId })!, +}: ValidatorProps): ts.ArrowFunction | undefined => { + if (!plugin.config.validator.request) return; + + const validator = plugin.getPluginOrThrow(plugin.config.validator.request); + if (!validator.api.createRequestValidator) return; + + return validator.api.createRequestValidator({ + file: plugin.gen.ensureFile(plugin.output), operation, // @ts-expect-error - plugin: pluginValidator, + plugin: validator, }); }; export const createResponseValidator = ({ operation, plugin, -}: { - operation: IR.OperationObject; - plugin: HeyApiSdkPlugin['Instance']; -}) => { - if (!plugin.config.validator.response) { - return; - } - - const pluginValidator = plugin.getPlugin(plugin.config.validator.response); - if (!pluginValidator || !pluginValidator.api.createResponseValidator) { - return; - } - - return pluginValidator.api.createResponseValidator({ - file: plugin.context.file({ id: sdkId })!, +}: ValidatorProps): ts.ArrowFunction | undefined => { + if (!plugin.config.validator.response) return; + + const validator = plugin.getPluginOrThrow(plugin.config.validator.response); + if (!validator.api.createResponseValidator) return; + + return validator.api.createResponseValidator({ + file: plugin.gen.ensureFile(plugin.output), operation, // @ts-expect-error - plugin: pluginValidator, + plugin: validator, }); }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/transformers/api.ts b/packages/openapi-ts/src/plugins/@hey-api/transformers/api.ts new file mode 100644 index 000000000..8fbf60bf9 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/api.ts @@ -0,0 +1,26 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = 'response' | 'response-ref'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `response`: `operation.id` string + * - `response-ref`: `$ref` JSON pointer + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/transformers'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts b/packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts index 5784c68fb..7eeb61cd5 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts @@ -1,19 +1,45 @@ import { definePluginConfig } from '../../shared/utils/config'; +import { Api } from './api'; +import { bigIntExpressions, dateExpressions } from './expressions'; import { handler } from './plugin'; import { handlerLegacy } from './plugin-legacy'; import type { HeyApiTransformersPlugin } from './types'; export const defaultConfig: HeyApiTransformersPlugin['Config'] = { + api: new Api({ + name: '@hey-api/transformers', + }), config: { bigInt: true, dates: true, exportFromIndex: false, + transformers: [], + typeTransformers: [], }, dependencies: ['@hey-api/typescript'], handler, handlerLegacy, name: '@hey-api/transformers', output: 'transformers', + resolveConfig: (plugin) => { + if (!plugin.config.transformers) { + plugin.config.transformers = []; + } + + if (plugin.config.dates) { + plugin.config.transformers = [ + ...plugin.config.transformers, + dateExpressions, + ]; + } + + if (plugin.config.bigInt) { + plugin.config.transformers = [ + ...plugin.config.transformers, + bigIntExpressions, + ]; + } + }, tags: ['transformer'], }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/transformers/expressions.ts b/packages/openapi-ts/src/plugins/@hey-api/transformers/expressions.ts index d75ed922c..b21d59a79 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/expressions.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/expressions.ts @@ -1,6 +1,6 @@ +import type { ICodegenFile } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import type { GeneratedFile } from '../../../generate/file'; import type { IR } from '../../../ir/types'; import { tsc } from '../../../tsc'; import type { UserConfig } from './types'; @@ -13,7 +13,7 @@ export type ExpressionTransformer = ({ }: { config: Omit; dataExpression?: ts.Expression | string; - file: GeneratedFile; + file: ICodegenFile; schema: IR.SchemaObject; }) => Array | undefined; diff --git a/packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts index 66b0d7064..18261c3d5 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts @@ -1,82 +1,16 @@ import ts from 'typescript'; -import type { - EnsureUniqueIdentifierData, - GeneratedFile, -} from '../../../generate/file'; -import { parseRef } from '../../../generate/file'; -import type { Identifier, Namespace } from '../../../generate/file/types'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import { createOperationKey, operationResponsesMap, } from '../../../ir/operation'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; -import { stringCase } from '../../../utils/stringCase'; -import { typesId } from '../typescript/ref'; -import { bigIntExpressions, dateExpressions } from './expressions'; +import { refToName } from '../../../utils/ref'; import type { HeyApiTransformersPlugin } from './types'; -interface OperationIRRef { - /** - * Operation ID - */ - id: string; -} - -export const operationTransformerIrRef = ({ - id, - type, -}: OperationIRRef & { - type: 'data' | 'error' | 'response'; -}): string => { - let affix = ''; - switch (type) { - case 'data': - affix = 'DataResponseTransformer'; - break; - case 'error': - affix = 'ErrorResponseTransformer'; - break; - case 'response': - affix = 'ResponseTransformer'; - break; - } - const irRef = '#/ir/'; - return `${irRef}${stringCase({ - // TODO: parser - do not pascalcase for functions, only for types - case: 'camelCase', - value: id, - })}${affix}`; -}; - -const schemaIrRef = ({ - $ref, - type, -}: { - $ref: string; - type: 'response'; -}): string => { - let affix = ''; - switch (type) { - case 'response': - affix = 'SchemaResponseTransformer'; - break; - } - const parts = $ref.split('/'); - return `${parts.slice(0, parts.length - 1).join('/')}/${stringCase({ - case: 'camelCase', - value: parts[parts.length - 1]!, - })}${affix}`; -}; - -export const schemaResponseTransformerRef = ({ - $ref, -}: { - $ref: string; -}): string => schemaIrRef({ $ref, type: 'response' }); - -export const transformersId = 'transformers'; const dataVariableName = 'data'; const ensureStatements = ( @@ -117,36 +51,6 @@ const schemaResponseTransformerNodes = ({ return nodes; }; -/** - * Prevents a specific identifier from being created. This is useful for - * transformers where we know a certain transformer won't be needed, and - * we want to avoid attempting to create since we know it won't happen. - */ -const blockIdentifier = ({ - $ref, - file, - namespace, -}: Pick & { - file: GeneratedFile; - namespace: Namespace; -}): Identifier => { - const { name, ref } = parseRef($ref); - const refValue = - file.identifiers[name.toLocaleLowerCase()]?.[namespace]?.[ref]; - if (!refValue) { - throw new Error( - `Identifier for $ref ${$ref} in namespace ${namespace} not found`, - ); - } - - refValue.name = false; - - return { - created: false, - name: refValue.name, - }; -}; - const processSchemaType = ({ dataExpression, plugin, @@ -156,16 +60,24 @@ const processSchemaType = ({ plugin: HeyApiTransformersPlugin['Instance']; schema: IR.SchemaObject; }): Array => { - const file = plugin.context.file({ id: transformersId })!; + const f = plugin.gen.ensureFile(plugin.output); if (schema.$ref) { - let identifier = file.identifier({ - $ref: schemaResponseTransformerRef({ $ref: schema.$ref }), - create: true, - namespace: 'value', - }); + const selector = plugin.api.getSelector('response-ref', schema.$ref); + let symbolResponseTransformerRef = f.selectSymbolFirst(selector); + + if (!symbolResponseTransformerRef) { + symbolResponseTransformerRef = f.addSymbol({ + name: buildName({ + config: { + case: 'camelCase', + name: '{{name}}SchemaResponseTransformer', + }, + name: refToName(schema.$ref), + }), + selector, + }); - if (identifier.created && identifier.name) { // create each schema response transformer only once const refSchema = plugin.context.resolveIrRef( schema.$ref, @@ -188,23 +100,20 @@ const processSchemaType = ({ ], statements: ensureStatements(nodes), }), - name: identifier.name, + name: symbolResponseTransformerRef.placeholder, }); - file.add(node); + symbolResponseTransformerRef.update({ value: node }); } else { // the created schema response transformer was empty, do not generate // it and prevent any future attempts - identifier = blockIdentifier({ - $ref: schemaResponseTransformerRef({ $ref: schema.$ref }), - file, - namespace: 'value', - }); + symbolResponseTransformerRef.update({ value: null }); } } - if (identifier.name) { + symbolResponseTransformerRef = f.selectSymbolFirst(selector); + if (symbolResponseTransformerRef?.value) { const callExpression = tsc.callExpression({ - functionName: identifier.name, + functionName: symbolResponseTransformerRef.placeholder, parameters: [dataExpression], }); @@ -401,11 +310,11 @@ const processSchemaType = ({ } } - for (const transformer of plugin.config.transformers ?? []) { + for (const transformer of plugin.config.transformers) { const t = transformer({ config: plugin.config, dataExpression, - file, + file: f, schema, }); if (t) { @@ -418,31 +327,15 @@ const processSchemaType = ({ // handles only response transformers for now export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { - const file = plugin.createFile({ - id: transformersId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); - if (plugin.config.dates) { - plugin.config.transformers = [ - ...(plugin.config.transformers ?? []), - dateExpressions, - ]; - } - - if (plugin.config.bigInt) { - plugin.config.transformers = [ - ...(plugin.config.transformers ?? []), - bigIntExpressions, - ]; - } - plugin.forEach('operation', ({ operation }) => { const { response } = operationResponsesMap(operation); - - if (!response) { - return; - } + if (!response) return; if (response.items && response.items.length > 1) { if (plugin.context.config.logs.level === 'debug') { @@ -453,35 +346,30 @@ export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { return; } - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const responseName = fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'response' }), + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + const symbolResponse = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('response', operation.id), ); - if (!responseName) { - return; - } + if (!symbolResponse) return; - let identifierResponseTransformer = file.identifier({ - $ref: operationTransformerIrRef({ id: operation.id, type: 'response' }), - create: true, - namespace: 'value', + const symbolResponseTransformer = f.addSymbol({ + name: buildName({ + config: { + case: 'camelCase', + name: '{{name}}ResponseTransformer', + }, + name: operation.id, + }), + selector: plugin.api.getSelector('response', operation.id), }); - if (!identifierResponseTransformer.name) { - return; - } // TODO: parser - consider handling simple string response which is also a date const nodes = schemaResponseTransformerNodes({ plugin, schema: response }); if (nodes.length) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: responseName, + f.addImport({ + from: symbolResponse.file, + typeNames: [symbolResponse.placeholder], }); const responseTransformerNode = tsc.constVariable({ exportConst: true, @@ -497,28 +385,17 @@ export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { ], returnType: tsc.typeReferenceNode({ typeArguments: [ - tsc.typeReferenceNode({ - typeName: responseName, - }), + tsc.typeReferenceNode({ typeName: symbolResponse.placeholder }), ], typeName: 'Promise', }), statements: ensureStatements(nodes), }), - name: identifierResponseTransformer.name, + name: symbolResponseTransformer.placeholder, }); - file.add(responseTransformerNode); + symbolResponseTransformer.update({ value: responseTransformerNode }); } else { - // the created schema response transformer was empty, do not generate - // it and prevent any future attempts - identifierResponseTransformer = blockIdentifier({ - $ref: operationTransformerIrRef({ - id: operation.id, - type: 'response', - }), - file, - namespace: 'value', - }); + symbolResponseTransformer.update({ value: null }); } }); }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/transformers/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/transformers/types.d.ts index 54054d89f..c14b4edad 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/types.d.ts @@ -1,8 +1,9 @@ +import type { ICodegenFile } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import type { GeneratedFile } from '../../../generate/file'; import type { IR } from '../../../ir/types'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; import type { ExpressionTransformer } from './expressions'; /** @@ -13,7 +14,7 @@ export type TypeTransformer = ({ file, schema, }: { - file: GeneratedFile; + file: ICodegenFile; schema: IR.SchemaObject; }) => ts.TypeNode | undefined; @@ -47,11 +48,46 @@ export type UserConfig = Plugin.Name<'@hey-api/transformers'> & { * Custom transforms to apply to the generated code. */ transformers?: ReadonlyArray; - /** * Custom type transformers that modify the TypeScript types generated. */ typeTransformers?: ReadonlyArray; }; -export type HeyApiTransformersPlugin = DefinePlugin; +export type Config = Plugin.Name<'@hey-api/transformers'> & { + /** + * Convert long integers into BigInt values? + * + * @default true + */ + bigInt: boolean; + /** + * Convert date strings into Date objects? + * + * @default true + */ + dates: boolean; + /** + * Should the exports from the generated files be re-exported in the index + * barrel file? + * + * @default false + */ + exportFromIndex: boolean; + /** + * Name of the generated file. + * + * @default 'transformers' + */ + output: string; + /** + * Custom transforms to apply to the generated code. + */ + transformers: ReadonlyArray; + /** + * Custom type transformers that modify the TypeScript types generated. + */ + typeTransformers: ReadonlyArray; +}; + +export type HeyApiTransformersPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/api.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/api.ts index 114f026f9..2513cee15 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/api.ts @@ -1,58 +1,54 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import type { IR } from '../../../ir/types'; +import type { Plugin } from '../../types'; import { schemaToType } from './plugin'; -type GetIdArgs = - | { - type: 'ClientOptions' | 'Webhooks'; - } - | { - operation: IR.OperationObject; - type: - | 'data' - | 'error' - | 'errors' - | 'response' - | 'responses' - | 'webhook-payload' - | 'webhook-request'; - } - | { - type: 'ref'; - value: string; - }; +type SelectorType = + | 'ClientOptions' + | 'data' + | 'error' + | 'errors' + | 'ref' + | 'response' + | 'responses' + | 'webhook-payload' + | 'webhook-request' + | 'Webhooks'; -const getId = (args: GetIdArgs): string => { - switch (args.type) { - case 'data': - case 'error': - case 'errors': - case 'response': - case 'responses': - case 'webhook-payload': - case 'webhook-request': - return `${args.operation.id}-${args.type}`; - case 'ref': - return args.value; - default: - return args.type; - } -}; +type SchemaToTypeArgs = Omit[0], 'onRef'> & + Pick[0]>, 'onRef'>; -export type Api = { - getId: (args: GetIdArgs) => string; - schemaToType: ( - args: Omit[0], 'onRef'> & - Pick[0]>, 'onRef'>, - ) => ts.TypeNode; +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `ClientOptions`: never + * - `data`: `operation.id` string + * - `error`: `operation.id` string + * - `errors`: `operation.id` string + * - `ref`: `$ref` JSON pointer + * - `response`: `operation.id` string + * - `responses`: `operation.id` string + * - `webhook-payload`: `operation.id` string + * - `webhook-request`: `operation.id` string + * - `Webhooks`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + schemaToType: (args: SchemaToTypeArgs) => ts.TypeNode; }; -export const api: Api = { - getId, - schemaToType: (args) => - schemaToType({ - onRef: undefined, - ...args, - }), -}; +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@hey-api/typescript'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } + + schemaToType(args: SchemaToTypeArgs): ts.TypeNode { + return schemaToType({ onRef: undefined, ...args }); + } +} diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/clientOptions.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/clientOptions.ts index ce25cbce1..5500d8f82 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/clientOptions.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/clientOptions.ts @@ -1,11 +1,10 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import ts from 'typescript'; -import type { NodeInfo } from '../../../generate/file/types'; import type { IR } from '../../../ir/types'; import { tsc } from '../../../tsc'; import { parseUrl } from '../../../utils/url'; import { getClientBaseUrlKey, getClientPlugin } from '../client-core/utils'; -import { typesId } from './ref'; import type { HeyApiTypeScriptPlugin } from './types'; const stringType = tsc.keywordTypeNode({ keyword: 'string' }); @@ -31,16 +30,14 @@ const serverToBaseUrlType = ({ server }: { server: IR.ServerObject }) => { }; export const createClientOptions = ({ - nodeInfo, plugin, servers, + symbolClientOptions, }: { - nodeInfo: NodeInfo; plugin: HeyApiTypeScriptPlugin['Instance']; servers: ReadonlyArray; + symbolClientOptions: ICodegenSymbolOut; }) => { - const file = plugin.context.file({ id: typesId })!; - const client = getClientPlugin(plugin.context.config); const types: Array = servers.map((server) => @@ -69,9 +66,9 @@ export const createClientOptions = ({ useLegacyResolution: false, }); const node = tsc.typeAliasDeclaration({ - exportType: nodeInfo.exported, - name: nodeInfo.node, + exportType: true, + name: symbolClientOptions.placeholder, type, }); - file.add(node); + symbolClientOptions.update({ value: node }); }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts index 2683d5545..1ce3c1908 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts @@ -1,11 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; -import { api } from './api'; +import { Api } from './api'; import { handler } from './plugin'; import { handlerLegacy } from './plugin-legacy'; import type { HeyApiTypeScriptPlugin } from './types'; export const defaultConfig: HeyApiTypeScriptPlugin['Config'] = { - api, + api: new Api({ + name: '@hey-api/typescript', + }), config: { case: 'PascalCase', exportFromIndex: true, diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts new file mode 100644 index 000000000..7908f08fb --- /dev/null +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts @@ -0,0 +1,164 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type ts from 'typescript'; + +import type { IR } from '../../../ir/types'; +import { tsc } from '../../../tsc'; +import { numberRegExp } from '../../../utils/regexp'; +import { stringCase } from '../../../utils/stringCase'; +import { createSchemaComment } from '../../shared/utils/schema'; +import type { HeyApiTypeScriptPlugin } from './types'; + +const schemaToEnumObject = ({ + plugin, + schema, +}: { + plugin: HeyApiTypeScriptPlugin['Instance']; + schema: IR.SchemaObject; +}) => { + const typeofItems: Array< + | 'bigint' + | 'boolean' + | 'function' + | 'number' + | 'object' + | 'string' + | 'symbol' + | 'undefined' + > = []; + + const obj = (schema.items ?? []).map((item, index) => { + const typeOfItemConst = typeof item.const; + + if (!typeofItems.includes(typeOfItemConst)) { + // track types of enum values because some modes support + // only enums with string and number types + typeofItems.push(typeOfItemConst); + } + + let key: string | undefined; + if (item.title) { + key = item.title; + } else if (typeOfItemConst === 'number' || typeOfItemConst === 'string') { + key = `${item.const}`; + } else if (typeOfItemConst === 'boolean') { + key = item.const ? 'true' : 'false'; + } else if (item.const === null) { + key = 'null'; + } else { + key = `${index}`; + } + + if (key) { + key = stringCase({ + case: plugin.config.enums.case, + stripLeadingSeparators: false, + value: key, + }); + + numberRegExp.lastIndex = 0; + // TypeScript enum keys cannot be numbers + if ( + numberRegExp.test(key) && + plugin.config.enums.enabled && + (plugin.config.enums.mode === 'typescript' || + plugin.config.enums.mode === 'typescript-const') + ) { + key = `_${key}`; + } + } + + return { + comments: createSchemaComment({ schema: item }), + key, + value: item.const, + }; + }); + + return { + obj, + typeofItems, + }; +}; + +export const exportType = ({ + plugin, + schema, + symbol, + type, +}: { + plugin: HeyApiTypeScriptPlugin['Instance']; + schema: IR.SchemaObject; + symbol: ICodegenSymbolOut; + type: ts.TypeNode; +}) => { + // root enums have an additional export + if (schema.type === 'enum' && plugin.config.enums.enabled) { + const enumObject = schemaToEnumObject({ plugin, schema }); + + if (plugin.config.enums.mode === 'javascript') { + // JavaScript enums might want to ignore null values + if ( + plugin.config.enums.constantsIgnoreNull && + enumObject.typeofItems.includes('object') + ) { + enumObject.obj = enumObject.obj.filter((item) => item.value !== null); + } + + const objectNode = tsc.constVariable({ + assertion: 'const', + comment: createSchemaComment({ schema }), + exportConst: true, + expression: tsc.objectExpression({ + multiLine: true, + obj: enumObject.obj, + }), + name: symbol.placeholder, + }); + + const typeofType = tsc.typeOfExpression({ + text: symbol.placeholder, + }) as unknown as ts.TypeNode; + const node = tsc.typeAliasDeclaration({ + comment: createSchemaComment({ schema }), + exportType: true, + name: symbol.placeholder, + type: tsc.indexedAccessTypeNode({ + indexType: tsc.typeOperatorNode({ + operator: 'keyof', + type: typeofType, + }), + objectType: typeofType, + }), + }); + + symbol.update({ value: [objectNode, node] }); + return; + } else if ( + plugin.config.enums.mode === 'typescript' || + plugin.config.enums.mode === 'typescript-const' + ) { + // TypeScript enums support only string and number values + const shouldCreateTypeScriptEnum = !enumObject.typeofItems.some( + (type) => type !== 'number' && type !== 'string', + ); + if (shouldCreateTypeScriptEnum) { + const enumNode = tsc.enumDeclaration({ + asConst: plugin.config.enums.mode === 'typescript-const', + leadingComment: createSchemaComment({ schema }), + name: symbol.placeholder, + obj: enumObject.obj, + }); + symbol.update({ value: enumNode }); + return; + } + } + } + + const node = tsc.typeAliasDeclaration({ + comment: createSchemaComment({ schema }), + exportType: true, + name: symbol.placeholder, + type, + }); + symbol.update({ value: node }); +}; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts index 7d9e6e8bd..743c12ae6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts @@ -1,12 +1,9 @@ -import ts from 'typescript'; - import { operationResponsesMap } from '../../../ir/operation'; import { deduplicateSchema } from '../../../ir/schema'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { schemaToType } from './plugin'; -import { typesId } from './ref'; import type { HeyApiTypeScriptPlugin, PluginState } from './types'; // TODO: exported just for @pinia/colada, remove export once that plugin does not depend on it @@ -55,7 +52,6 @@ const operationToDataType = ({ plugin: HeyApiTypeScriptPlugin['Instance']; state: PluginState; }) => { - const file = plugin.context.file({ id: typesId })!; const data: IR.SchemaObject = { type: 'object', }; @@ -126,17 +122,14 @@ const operationToDataType = ({ data.required = dataRequired; - const name = buildName({ - config: plugin.config.requests, - name: operation.id, + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f.addSymbol({ + name: buildName({ + config: plugin.config.requests, + name: operation.id, + }), + selector: plugin.api.getSelector('data', operation.id), }); - const nodeInfo = file.updateNode( - plugin.api.getId({ operation, type: 'data' }), - { - exported: true, - name, - }, - ); const type = schemaToType({ onRef: undefined, plugin, @@ -144,11 +137,11 @@ const operationToDataType = ({ state, }); const node = tsc.typeAliasDeclaration({ - exportType: nodeInfo.exported, - name: nodeInfo.node, + exportType: true, + name: symbol.placeholder, type, }); - file.add(node); + symbol.update({ value: node }); }; export const operationToType = ({ @@ -162,23 +155,19 @@ export const operationToType = ({ }) => { operationToDataType({ operation, plugin, state }); - const file = plugin.context.file({ id: typesId })!; + const f = plugin.gen.ensureFile(plugin.output); const { error, errors, response, responses } = operationResponsesMap(operation); if (errors) { - const name = buildName({ - config: plugin.config.errors, - name: operation.id, + const symbolErrors = f.addSymbol({ + name: buildName({ + config: plugin.config.errors, + name: operation.id, + }), + selector: plugin.api.getSelector('errors', operation.id), }); - const nodeInfo = file.updateNode( - plugin.api.getId({ operation, type: 'errors' }), - { - exported: true, - name, - }, - ); const type = schemaToType({ onRef: undefined, plugin, @@ -186,55 +175,49 @@ export const operationToType = ({ state, }); const node = tsc.typeAliasDeclaration({ - exportType: nodeInfo.exported, - name: nodeInfo.node, + exportType: true, + name: symbolErrors.placeholder, type, }); - file.add(node); + symbolErrors.update({ value: node }); if (error) { - const name = buildName({ - config: { - case: plugin.config.errors.case, - name: plugin.config.errors.error, - }, - name: operation.id, + const symbol = f.addSymbol({ + name: buildName({ + config: { + case: plugin.config.errors.case, + name: plugin.config.errors.error, + }, + name: operation.id, + }), + selector: plugin.api.getSelector('error', operation.id), }); - const errorNodeInfo = file.updateNode( - plugin.api.getId({ operation, type: 'error' }), - { - exported: true, - name, - }, - ); const type = tsc.indexedAccessTypeNode({ - indexType: ts.factory.createTypeOperatorNode( - ts.SyntaxKind.KeyOfKeyword, - nodeInfo.node, - ), - objectType: nodeInfo.node, + indexType: tsc.typeOperatorNode({ + operator: 'keyof', + type: tsc.typeReferenceNode({ typeName: symbolErrors.placeholder }), + }), + objectType: tsc.typeReferenceNode({ + typeName: symbolErrors.placeholder, + }), }); const node = tsc.typeAliasDeclaration({ - exportType: errorNodeInfo.exported, - name: errorNodeInfo.node, + exportType: true, + name: symbol.placeholder, type, }); - file.add(node); + symbol.update({ value: node }); } } if (responses) { - const name = buildName({ - config: plugin.config.responses, - name: operation.id, + const symbolResponses = f.addSymbol({ + name: buildName({ + config: plugin.config.responses, + name: operation.id, + }), + selector: plugin.api.getSelector('responses', operation.id), }); - const nodeInfo = file.updateNode( - plugin.api.getId({ operation, type: 'responses' }), - { - exported: true, - name, - }, - ); const type = schemaToType({ onRef: undefined, plugin, @@ -242,40 +225,40 @@ export const operationToType = ({ state, }); const node = tsc.typeAliasDeclaration({ - exportType: nodeInfo.exported, - name: nodeInfo.node, + exportType: true, + name: symbolResponses.placeholder, type, }); - file.add(node); + symbolResponses.update({ value: node }); if (response) { - const name = buildName({ - config: { - case: plugin.config.responses.case, - name: plugin.config.responses.response, - }, - name: operation.id, + const symbol = f.addSymbol({ + name: buildName({ + config: { + case: plugin.config.responses.case, + name: plugin.config.responses.response, + }, + name: operation.id, + }), + selector: plugin.api.getSelector('response', operation.id), }); - const responseNodeInfo = file.updateNode( - plugin.api.getId({ operation, type: 'response' }), - { - exported: true, - name, - }, - ); const type = tsc.indexedAccessTypeNode({ - indexType: ts.factory.createTypeOperatorNode( - ts.SyntaxKind.KeyOfKeyword, - nodeInfo.node, - ), - objectType: nodeInfo.node, + indexType: tsc.typeOperatorNode({ + operator: 'keyof', + type: tsc.typeReferenceNode({ + typeName: symbolResponses.placeholder, + }), + }), + objectType: tsc.typeReferenceNode({ + typeName: symbolResponses.placeholder, + }), }); const node = tsc.typeAliasDeclaration({ - exportType: responseNodeInfo.exported, - name: responseNodeInfo.node, + exportType: true, + name: symbol.placeholder, type, }); - file.add(node); + symbol.update({ value: node }); } } }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts index f2d9f9a5a..da8e5997c 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts @@ -1,5 +1,7 @@ -import ts from 'typescript'; +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type ts from 'typescript'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import { deduplicateSchema } from '../../../ir/schema'; import type { IR } from '../../../ir/types'; import { ensureValidIdentifier } from '../../../openApi/shared/utils/identifier'; @@ -7,96 +9,23 @@ import { buildName } from '../../../openApi/shared/utils/name'; import type { Property } from '../../../tsc'; import { tsc } from '../../../tsc'; import { refToName } from '../../../utils/ref'; -import { numberRegExp } from '../../../utils/regexp'; import { stringCase } from '../../../utils/stringCase'; import { fieldName } from '../../shared/utils/case'; import { createSchemaComment } from '../../shared/utils/schema'; import { createClientOptions } from './clientOptions'; +import { exportType } from './export'; import { operationToType } from './operation'; -import { typesId } from './ref'; import type { HeyApiTypeScriptPlugin, PluginState } from './types'; import { webhookToType } from './webhook'; import { createWebhooks } from './webhooks'; -export type OnRef = (id: string) => void; +export type OnRef = (symbol: ICodegenSymbolOut) => void; interface SchemaWithType['type']> extends Omit { type: Extract['type'], T>; } -const schemaToEnumObject = ({ - plugin, - schema, -}: { - plugin: HeyApiTypeScriptPlugin['Instance']; - schema: IR.SchemaObject; -}) => { - const typeofItems: Array< - | 'bigint' - | 'boolean' - | 'function' - | 'number' - | 'object' - | 'string' - | 'symbol' - | 'undefined' - > = []; - - const obj = (schema.items ?? []).map((item, index) => { - const typeOfItemConst = typeof item.const; - - if (!typeofItems.includes(typeOfItemConst)) { - // track types of enum values because some modes support - // only enums with string and number types - typeofItems.push(typeOfItemConst); - } - - let key: string | undefined; - if (item.title) { - key = item.title; - } else if (typeOfItemConst === 'number' || typeOfItemConst === 'string') { - key = `${item.const}`; - } else if (typeOfItemConst === 'boolean') { - key = item.const ? 'true' : 'false'; - } else if (item.const === null) { - key = 'null'; - } else { - key = `${index}`; - } - - if (key) { - key = stringCase({ - case: plugin.config.enums.case, - stripLeadingSeparators: false, - value: key, - }); - - numberRegExp.lastIndex = 0; - // TypeScript enum keys cannot be numbers - if ( - numberRegExp.test(key) && - plugin.config.enums.enabled && - (plugin.config.enums.mode === 'typescript' || - plugin.config.enums.mode === 'typescript-const') - ) { - key = `_${key}`; - } - } - - return { - comments: createSchemaComment({ schema: item }), - key, - value: item.const, - }; - }); - - return { - obj, - typeofItems, - }; -}; - const arrayTypeToIdentifier = ({ onRef, plugin, @@ -436,8 +365,8 @@ const schemaTypeToIdentifier = ({ const transformersPlugin = plugin.getPlugin('@hey-api/transformers'); if (transformersPlugin?.config.typeTransformers) { for (const typeTransformer of transformersPlugin.config.typeTransformers) { - const file = plugin.context.file({ id: typesId })!; - const typeNode = typeTransformer({ file, schema }); + const f = plugin.gen.ensureFile(plugin.output); + const typeNode = typeTransformer({ file: f, schema }); if (typeNode) { return typeNode; } @@ -527,14 +456,16 @@ export const schemaToType = ({ schema: IR.SchemaObject; state: PluginState; }): ts.TypeNode => { - const file = plugin.context.file({ id: typesId })!; + const f = plugin.gen.ensureFile(plugin.output); if (schema.$ref) { + const symbol = f.ensureSymbol({ + selector: plugin.api.getSelector('ref', schema.$ref), + }); if (onRef) { - onRef(plugin.api.getId({ type: 'ref', value: schema.$ref })); + onRef(symbol); } - return file.getNode(plugin.api.getId({ type: 'ref', value: schema.$ref })) - .node; + return tsc.typeReferenceNode({ typeName: symbol.placeholder }); } if (schema.type) { @@ -570,95 +501,6 @@ export const schemaToType = ({ }); }; -const exportType = ({ - id, - plugin, - schema, - type, -}: { - id: string; - plugin: HeyApiTypeScriptPlugin['Instance']; - schema: IR.SchemaObject; - type: ts.TypeNode; -}) => { - const file = plugin.context.file({ id: typesId })!; - - const nodeInfo = file.getNode(plugin.api.getId({ type: 'ref', value: id })); - - // root enums have an additional export - if (schema.type === 'enum' && plugin.config.enums.enabled) { - const enumObject = schemaToEnumObject({ plugin, schema }); - - if (plugin.config.enums.mode === 'javascript') { - // JavaScript enums might want to ignore null values - if ( - plugin.config.enums.constantsIgnoreNull && - enumObject.typeofItems.includes('object') - ) { - enumObject.obj = enumObject.obj.filter((item) => item.value !== null); - } - - const objectNode = tsc.constVariable({ - assertion: 'const', - comment: createSchemaComment({ schema }), - exportConst: nodeInfo.exported, - expression: tsc.objectExpression({ - multiLine: true, - obj: enumObject.obj, - }), - name: nodeInfo.node, - }); - file.add(objectNode); - - // TODO: https://github.com/hey-api/openapi-ts/issues/2289 - const typeofType = tsc.typeOfExpression({ - text: nodeInfo.node.typeName as unknown as string, - }) as unknown as ts.TypeNode; - const keyofType = ts.factory.createTypeOperatorNode( - ts.SyntaxKind.KeyOfKeyword, - typeofType, - ); - const node = tsc.typeAliasDeclaration({ - comment: createSchemaComment({ schema }), - exportType: nodeInfo.exported, - name: nodeInfo.node, - type: tsc.indexedAccessTypeNode({ - indexType: keyofType, - objectType: typeofType, - }), - }); - file.add(node); - return; - } else if ( - plugin.config.enums.mode === 'typescript' || - plugin.config.enums.mode === 'typescript-const' - ) { - // TypeScript enums support only string and number values - const shouldCreateTypeScriptEnum = !enumObject.typeofItems.some( - (type) => type !== 'number' && type !== 'string', - ); - if (shouldCreateTypeScriptEnum) { - const enumNode = tsc.enumDeclaration({ - asConst: plugin.config.enums.mode === 'typescript-const', - leadingComment: createSchemaComment({ schema }), - name: nodeInfo.node, - obj: enumObject.obj, - }); - file.add(enumNode); - return; - } - } - } - - const node = tsc.typeAliasDeclaration({ - comment: createSchemaComment({ schema }), - exportType: nodeInfo.exported, - name: nodeInfo.node, - type, - }); - file.add(node); -}; - const handleComponent = ({ id, plugin, @@ -670,65 +512,56 @@ const handleComponent = ({ schema: IR.SchemaObject; state: PluginState; }) => { - const file = plugin.context.file({ id: typesId })!; const type = schemaToType({ onRef: undefined, plugin, schema, state }); - const name = buildName({ - config: plugin.config.definitions, - name: refToName(id), - }); - file.updateNode(plugin.api.getId({ type: 'ref', value: id }), { - exported: true, - name, - }); + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f + .ensureSymbol({ selector: plugin.api.getSelector('ref', id) }) + .update({ + name: buildName({ + config: plugin.config.definitions, + name: refToName(id), + }), + }); exportType({ - id, plugin, schema, + symbol, type, }); }; export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { - const state: PluginState = { - usedTypeIDs: new Set(), - }; - - const file = plugin.createFile({ - case: plugin.config.case, - id: typesId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); // reserve identifier for ClientOptions - const clientOptionsName = buildName({ - config: { - case: plugin.config.case, - }, - name: 'ClientOptions', + const symbolClientOptions = f.addSymbol({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'ClientOptions', + }), + selector: plugin.api.getSelector('ClientOptions'), }); - const clientOptionsNodeInfo = file.updateNode( - plugin.api.getId({ type: 'ClientOptions' }), - { - exported: true, - name: clientOptionsName, - }, - ); // reserve identifier for Webhooks - const webhooksName = buildName({ - config: { - case: plugin.config.case, - }, - name: 'Webhooks', + const symbolWebhooks = f.addSymbol({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'Webhooks', + }), + selector: plugin.api.getSelector('Webhooks'), }); - const webhooksNodeInfo = file.updateNode( - plugin.api.getId({ type: 'Webhooks' }), - { - exported: true, - name: webhooksName, - }, - ); const servers: Array = []; + const state: PluginState = { + usedTypeIDs: new Set(), + }; const webhookNames: Array = []; plugin.forEach( @@ -739,38 +572,46 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { 'server', 'webhook', (event) => { - if (event.type === 'operation') { - operationToType({ operation: event.operation, plugin, state }); - } else if (event.type === 'parameter') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.parameter.schema, - state, - }); - } else if (event.type === 'requestBody') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.requestBody.schema, - state, - }); - } else if (event.type === 'schema') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.schema, - state, - }); - } else if (event.type === 'server') { - servers.push(event.server); - } else if (event.type === 'webhook') { - const webhookName = webhookToType({ - operation: event.operation, - plugin, - state, - }); - webhookNames.push(webhookName); + switch (event.type) { + case 'operation': + operationToType({ operation: event.operation, plugin, state }); + break; + case 'parameter': + handleComponent({ + id: event.$ref, + plugin, + schema: event.parameter.schema, + state, + }); + break; + case 'requestBody': + handleComponent({ + id: event.$ref, + plugin, + schema: event.requestBody.schema, + state, + }); + break; + case 'schema': + handleComponent({ + id: event.$ref, + plugin, + schema: event.schema, + state, + }); + break; + case 'server': + servers.push(event.server); + break; + case 'webhook': + webhookNames.push( + webhookToType({ + operation: event.operation, + plugin, + state, + }), + ); + break; } }, ); @@ -782,47 +623,51 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { }), name: 'T', }); + const symbolTypeId = f.addSymbol({ name: 'TypeID' }); const node = tsc.typeAliasDeclaration({ exportType: true, - name: 'TypeID', + name: symbolTypeId.placeholder, type: tsc.templateLiteralType({ value: [ - tsc.typeReferenceNode({ - typeName: 'T', - }), + tsc.typeReferenceNode({ typeName: 'T' }), '_', - tsc.keywordTypeNode({ - keyword: 'string', - }), + tsc.keywordTypeNode({ keyword: 'string' }), ], }), typeParameters: [typeParameter], }); - file.add(node); + symbolTypeId.update({ value: node }); for (const name of state.usedTypeIDs.values()) { - const typeName = ensureValidIdentifier( - stringCase({ - case: plugin.config.case, - value: name + '_id', - }), - ); + const symbolTypeName = f.addSymbol({ + name: ensureValidIdentifier( + stringCase({ + case: plugin.config.case, + value: `${name}_id`, + }), + ), + }); const node = tsc.typeAliasDeclaration({ exportType: true, - name: typeName, + name: symbolTypeName.placeholder, type: tsc.typeReferenceNode({ typeArguments: [ tsc.literalTypeNode({ literal: tsc.stringLiteral({ text: name }), }), ], - typeName: 'TypeID', + typeName: symbolTypeId.placeholder, }), }); - file.add(node); + symbolTypeName.update({ value: node }); } } - createClientOptions({ nodeInfo: clientOptionsNodeInfo, plugin, servers }); - createWebhooks({ nodeInfo: webhooksNodeInfo, plugin, webhookNames }); + createClientOptions({ plugin, servers, symbolClientOptions }); + createWebhooks({ symbolWebhooks, webhookNames }); + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/ref.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/ref.ts deleted file mode 100644 index 80e05eb1e..000000000 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/ref.ts +++ /dev/null @@ -1 +0,0 @@ -export const typesId = 'types'; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts index d53b6e719..965697341 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/types.d.ts @@ -1,6 +1,6 @@ import type { StringCase, StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; -import type { Api } from './api'; +import type { IApi } from './api'; export type EnumsType = 'javascript' | 'typescript' | 'typescript-const'; @@ -493,4 +493,4 @@ export interface PluginState { usedTypeIDs: Set; } -export type HeyApiTypeScriptPlugin = DefinePlugin; +export type HeyApiTypeScriptPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/webhook.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/webhook.ts index 94d648779..fbdf1e24b 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/webhook.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/webhook.ts @@ -3,7 +3,6 @@ import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createSchemaComment } from '../../shared/utils/schema'; import { schemaToType } from './plugin'; -import { typesId } from './ref'; import type { HeyApiTypeScriptPlugin, PluginState } from './types'; const operationToDataType = ({ @@ -15,7 +14,7 @@ const operationToDataType = ({ plugin: HeyApiTypeScriptPlugin['Instance']; state: PluginState; }): string => { - const file = plugin.context.file({ id: typesId })!; + const f = plugin.gen.ensureFile(plugin.output); const data: IR.SchemaObject = { type: 'object', @@ -27,18 +26,19 @@ const operationToDataType = ({ } if (operation.body) { - const name = buildName({ - config: { - case: plugin.config.webhooks.case, - name: plugin.config.webhooks.payload, - }, - name: operation.id, - }); - const id = plugin.api.getId({ operation, type: 'webhook-payload' }); - const nodeInfo = file.updateNode(id, { - exported: true, - name, - }); + const symbolWebhookPayload = f + .ensureSymbol({ + selector: plugin.api.getSelector('webhook-payload', operation.id), + }) + .update({ + name: buildName({ + config: { + case: plugin.config.webhooks.case, + name: plugin.config.webhooks.payload, + }, + name: operation.id, + }), + }); const type = schemaToType({ onRef: undefined, plugin, @@ -47,13 +47,19 @@ const operationToDataType = ({ }); const node = tsc.typeAliasDeclaration({ comment: createSchemaComment({ schema: operation.body.schema }), - exportType: nodeInfo.exported, - name: nodeInfo.node, + exportType: true, + name: symbolWebhookPayload.placeholder, type, }); - file.add(node); + symbolWebhookPayload.update({ value: node }); - data.properties.body = { $ref: id }; + f.ensureSymbol({ + selector: plugin.api.getSelector('ref', symbolWebhookPayload.placeholder), + }).update({ + name: symbolWebhookPayload.name, + placeholder: symbolWebhookPayload.placeholder, + }); + data.properties.body = { $ref: symbolWebhookPayload.placeholder }; dataRequired.push('body'); } else { data.properties.body = { type: 'never' }; @@ -70,17 +76,13 @@ const operationToDataType = ({ data.required = dataRequired; - const name = buildName({ - config: plugin.config.webhooks, - name: operation.id, + const symbolWebhookRequest = f.addSymbol({ + name: buildName({ + config: plugin.config.webhooks, + name: operation.id, + }), + selector: plugin.api.getSelector('webhook-request', operation.id), }); - const nodeInfo = file.updateNode( - plugin.api.getId({ operation, type: 'webhook-request' }), - { - exported: true, - name, - }, - ); const type = schemaToType({ onRef: undefined, plugin, @@ -88,13 +90,13 @@ const operationToDataType = ({ state, }); const node = tsc.typeAliasDeclaration({ - exportType: nodeInfo.exported, - name: nodeInfo.node, + exportType: true, + name: symbolWebhookRequest.placeholder, type, }); - file.add(node); + symbolWebhookRequest.update({ value: node }); - return name; + return symbolWebhookRequest.placeholder; }; export const webhookToType = ({ @@ -110,39 +112,4 @@ export const webhookToType = ({ return name; // don't handle webhook responses for now, users only need requestBody - - // const file = plugin.context.file({ id: typesId })!; - - // const { responses } = operationResponsesMap(operation); - - // const response = responses?.properties?.['200']; - - // if (response) { - // const name = buildName({ - // config: { - // ...plugin.config.responses, - // name: '{{name}}WebhookEvent', - // }, - // name: operation.id, - // }); - // const nodeInfo = file.updateNode( - // plugin.api.getId({ operation, type: 'webhook-response' }), - // { - // exported: true, - // name, - // }, - // ); - // const type = schemaToType({ - // onRef: undefined, - // plugin, - // schema: response, - // state, - // }); - // const node = tsc.typeAliasDeclaration({ - // exportType: nodeInfo.exported, - // name: nodeInfo.node, - // type, - // }); - // file.add(node); - // } }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/webhooks.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/webhooks.ts index 856146782..c39694fb6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/webhooks.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/webhooks.ts @@ -1,32 +1,25 @@ -import type { NodeInfo } from '../../../generate/file/types'; +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; + import { tsc } from '../../../tsc'; -import { typesId } from './ref'; -import type { HeyApiTypeScriptPlugin } from './types'; export const createWebhooks = ({ - nodeInfo, - plugin, + symbolWebhooks, webhookNames, }: { - nodeInfo: NodeInfo; - plugin: HeyApiTypeScriptPlugin['Instance']; + symbolWebhooks: ICodegenSymbolOut; webhookNames: ReadonlyArray; }) => { - const file = plugin.context.file({ id: typesId })!; - if (!webhookNames.length) return; const type = tsc.typeUnionNode({ types: webhookNames.map((name) => - tsc.typeReferenceNode({ - typeName: name, - }), + tsc.typeReferenceNode({ typeName: name }), ), }); const node = tsc.typeAliasDeclaration({ - exportType: nodeInfo.exported, - name: nodeInfo.node, + exportType: true, + name: symbolWebhooks.placeholder, type, }); - file.add(node); + symbolWebhooks.update({ value: node }); }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/__tests__/plugin.test.ts b/packages/openapi-ts/src/plugins/@pinia/colada/__tests__/plugin.test.ts deleted file mode 100644 index b118b0338..000000000 --- a/packages/openapi-ts/src/plugins/@pinia/colada/__tests__/plugin.test.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { describe, expect, it, vi } from 'vitest'; - -import type { IR } from '../../../../ir/types'; -import type { PiniaColadaPlugin } from '../types'; - -const createMockOperation = ( - method: IR.OperationObject['method'], - id = 'testOperation', - tags?: ReadonlyArray, -): IR.OperationObject => ({ - id, - method, - operationId: id, - path: '/test', - responses: {}, - tags, -}); - -const createMockPlugin = ( - config: Partial = {}, -): any => ({ - config: { - exportFromIndex: false, - groupByTag: false, - ...config, - }, - context: { - file: vi.fn(), - }, - createFile: vi.fn(() => ({ - add: vi.fn(), - identifier: vi.fn(() => ({ name: 'testIdentifier' })), - import: vi.fn(), - })), - getPlugin: vi.fn(() => ({ - config: { - responseStyle: 'response', - }, - })), -}); - -// Import the functions we want to test (we'll need to extract them from the plugin file) -// For now, let's test the logic through integration with the plugin -describe('@pinia/colada', () => { - describe('groupByTag', () => { - it('uses single file when groupByTag is false', () => { - const operation = createMockOperation('get', 'testOp', ['pet', 'store']); - const plugin = createMockPlugin({ groupByTag: false }); - - const expectedFileId = plugin.name || '@pinia/colada'; - const actualFileId = plugin.config.groupByTag - ? `${plugin.name || '@pinia/colada'}/${operation.tags?.[0] || 'default'}` - : plugin.name || '@pinia/colada'; - - expect(actualFileId).toBe(expectedFileId); - }); - - it('uses separate files by tag when groupByTag is true', () => { - const petOperation = createMockOperation('get', 'getPet', ['pet']); - const storeOperation = createMockOperation('get', 'getInventory', [ - 'store', - ]); - const plugin = createMockPlugin({ groupByTag: true }); - - const petFileId = plugin.config.groupByTag - ? `${plugin.name || '@pinia/colada'}/${petOperation.tags?.[0] || 'default'}` - : plugin.name || '@pinia/colada'; - const storeFileId = plugin.config.groupByTag - ? `${plugin.name || '@pinia/colada'}/${storeOperation.tags?.[0] || 'default'}` - : plugin.name || '@pinia/colada'; - - expect(petFileId).toBe('@pinia/colada/pet'); - expect(storeFileId).toBe('@pinia/colada/store'); - expect(petFileId).not.toBe(storeFileId); - }); - - it('uses default tag when operation has no tags and groupByTag is true', () => { - const operation = createMockOperation('get', 'testOp'); - const plugin = createMockPlugin({ groupByTag: true }); - - const fileId = plugin.config.groupByTag - ? `${plugin.name || '@pinia/colada'}/${operation.tags?.[0] || 'default'}` - : plugin.name || '@pinia/colada'; - - expect(fileId).toBe('@pinia/colada/default'); - }); - }); - - describe('config', () => { - it('uses default values', () => { - const plugin = createMockPlugin(); - expect(plugin.config.groupByTag).toBe(false); - expect(plugin.config.exportFromIndex).toBe(false); - }); - - it('allows overrides', () => { - const plugin = createMockPlugin({ - exportFromIndex: true, - groupByTag: true, - }); - expect(plugin.config.groupByTag).toBe(true); - expect(plugin.config.exportFromIndex).toBe(true); - }); - }); -}); diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/api.ts b/packages/openapi-ts/src/plugins/@pinia/colada/api.ts new file mode 100644 index 000000000..9af1e62ae --- /dev/null +++ b/packages/openapi-ts/src/plugins/@pinia/colada/api.ts @@ -0,0 +1,38 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | '_JSONValue' + | 'AxiosError' + | 'createQueryKey' + | 'queryOptionsFn' + | 'QueryKey' + | 'UseMutationOptions' + | 'UseQueryOptions'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `_JSONValue`: never + * - `AxiosError`: never + * - `createQueryKey`: never + * - `queryOptionsFn`: `operation.id` string + * - `QueryKey`: never + * - `UseMutationOptions`: never + * - `UseQueryOptions`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@pinia/colada'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/config.ts b/packages/openapi-ts/src/plugins/@pinia/colada/config.ts index b3d6050c0..13b181d52 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/config.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/config.ts @@ -1,13 +1,16 @@ import { definePluginConfig } from '../../shared/utils/config'; +import { Api } from './api'; import { handler } from './plugin'; import type { PiniaColadaPlugin } from './types'; export const defaultConfig: PiniaColadaPlugin['Config'] = { + api: new Api({ + name: '@pinia/colada', + }), config: { case: 'camelCase', comments: true, exportFromIndex: false, - groupByTag: false, }, dependencies: ['@hey-api/typescript', '@hey-api/sdk'], handler: handler as PiniaColadaPlugin['Handler'], diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts b/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts index 9e278ed6b..e18c2ce26 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts @@ -1,7 +1,7 @@ import type ts from 'typescript'; -import type { GeneratedFile } from '../../../generate/file'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createOperationComment, @@ -10,53 +10,41 @@ import { import { handleMeta } from './meta'; import type { PluginState } from './state'; import type { PiniaColadaPlugin } from './types'; -import { useTypeData, useTypeError, useTypeResponse } from './utils'; - -const mutationOptionsType = 'UseMutationOptions'; +import { useTypeData, useTypeError, useTypeResponse } from './useType'; export const createMutationOptions = ({ - file, operation, plugin, queryFn, state, }: { - file: GeneratedFile; operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; queryFn: string; state: PluginState; }): void => { - if ( - !plugin.config.mutationOptions.enabled || - !plugin.hooks.operation.isMutation(operation) - ) { - return; - } + const f = plugin.gen.ensureFile(plugin.output); if (!state.hasMutations) { state.hasMutations = true; - - file.import({ - asType: true, - module: plugin.name, - name: mutationOptionsType, - }); } - state.hasUsedQueryFn = true; + const symbolMutationOptionsType = f.ensureSymbol({ + name: 'UseMutationOptions', + selector: plugin.api.getSelector('UseMutationOptions'), + }); + f.addImport({ + from: plugin.name, + typeNames: [symbolMutationOptionsType.name], + }); - const typeData = useTypeData({ file, operation, plugin }); - const typeError = useTypeError({ file, operation, plugin }); - const typeResponse = useTypeResponse({ file, operation, plugin }); + state.hasUsedQueryFn = true; - const identifierMutationOptions = file.identifier({ - $ref: `#/pinia-colada-mutation-options/${operation.id}`, - case: plugin.config.mutationOptions.case, - create: true, - nameTransformer: plugin.config.mutationOptions.name, - namespace: 'value', - }); + const typeData = useTypeData({ operation, plugin }); + const typeError = useTypeError({ operation, plugin }); + const typeResponse = useTypeResponse({ operation, plugin }); + // TODO: better types syntax + const mutationType = `${symbolMutationOptionsType.placeholder}<${typeResponse}, ${typeData}, ${typeError}>`; const fnOptions = 'fnOptions'; @@ -85,7 +73,7 @@ export const createMutationOptions = ({ const statements: Array = []; - if (plugin.getPlugin('@hey-api/sdk')?.config.responseStyle === 'data') { + if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') { statements.push( tsc.returnVariable({ expression: awaitSdkExpression, @@ -134,6 +122,12 @@ export const createMutationOptions = ({ operation, }); + const symbolMutationOptions = f.addSymbol({ + name: buildName({ + config: plugin.config.mutationOptions, + name: operation.id, + }), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) @@ -147,8 +141,7 @@ export const createMutationOptions = ({ type: typeData, }, ], - // TODO: better types syntax - returnType: `${mutationOptionsType}<${typeResponse}, ${typeData}, ${typeError.name}>`, + returnType: mutationType, statements: [ tsc.returnStatement({ expression: tsc.objectExpression({ @@ -157,8 +150,7 @@ export const createMutationOptions = ({ }), ], }), - name: identifierMutationOptions.name || '', + name: symbolMutationOptions.placeholder, }); - - file.add(statement); + symbolMutationOptions.update({ value: statement }); }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts b/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts index 13248f753..13f78452a 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts @@ -1,30 +1,43 @@ -import type { GeneratedFile } from '../../../generate/file'; -import { tsc } from '../../../tsc'; +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; + +import { TypeScriptRenderer } from '../../../generate/renderer'; import { stringCase } from '../../../utils/stringCase'; -import { clientId } from '../../@hey-api/client-core/utils'; -import { sdkId } from '../../@hey-api/sdk/constants'; +import { getClientPlugin } from '../../@hey-api/client-core/utils'; import { operationClasses } from '../../@hey-api/sdk/operation'; import { serviceFunctionIdentifier } from '../../@hey-api/sdk/plugin-legacy'; import { createMutationOptions } from './mutationOptions'; import { createQueryOptions } from './queryOptions'; import type { PluginState } from './state'; import type { PiniaColadaPlugin } from './types'; -import { getFileForOperation } from './utils'; export const handler: PiniaColadaPlugin['Handler'] = ({ plugin }) => { - const files = new Map(); - const states = new Map(); + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), + }); - plugin.forEach('operation', ({ operation }) => { - const { file, state } = getFileForOperation({ - files, - operation, - plugin, - states, + const state: PluginState = { + hasCreateQueryKeyParamsFunction: false, + hasMutations: false, + hasQueries: false, + hasUsedQueryFn: false, + }; + + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirst( + sdkPlugin.api.getSelector('Options'), + ); + if (symbolOptions) { + f.addImport({ + from: symbolOptions.file, + typeNames: [symbolOptions.placeholder], }); + } + + plugin.forEach('operation', ({ operation }) => { state.hasUsedQueryFn = false; - const sdkPlugin = plugin.getPlugin('@hey-api/sdk')!; const classes = sdkPlugin.config.asClass ? operationClasses({ context: plugin.context, @@ -58,62 +71,61 @@ export const handler: PiniaColadaPlugin['Handler'] = ({ plugin }) => { ] ).join('.'); - createQueryOptions({ - file, - operation, - plugin, - queryFn, - state, - }); + if (plugin.hooks.operation.isQuery(operation)) { + if (plugin.config.queryOptions.enabled) { + createQueryOptions({ + operation, + plugin, + queryFn, + state, + }); + } + } - createMutationOptions({ - file, - operation, - plugin, - queryFn, - state, - }); + if (plugin.hooks.operation.isMutation(operation)) { + if (plugin.config.mutationOptions.enabled) { + createMutationOptions({ + operation, + plugin, + queryFn, + state, + }); + } + } if (state.hasUsedQueryFn) { - file.import({ - module: file.relativePathToFile({ context: plugin.context, id: sdkId }), - name: queryFn.split('.')[0]!, - }); + // TODO: make this work with static classes + const symbolFunction = plugin.gen.selectSymbolFirst( + sdkPlugin.api.getSelector('function', operation.id), + ); + if (symbolFunction) { + f.addImport({ + from: symbolFunction.file, + names: [symbolFunction.placeholder], + }); + } } }); - files.forEach((file, fileId) => { - const state = states.get(fileId)!; - - if (state.hasQueries) { - file.import({ - alias: '_heyApiClient', - module: file.relativePathToFile({ - context: plugin.context, - id: clientId, - }), - name: 'client', - }); + if (state.hasQueries) { + let symbolClient: ICodegenSymbolOut | undefined; + const client = getClientPlugin(plugin.context.config); + if (client.api && 'getSelector' in client.api) { + symbolClient = plugin.gen.selectSymbolFirst( + // @ts-expect-error + client.api.getSelector('client'), + ); + if (symbolClient) { + f.addImport({ + from: symbolClient.file, + names: [symbolClient.placeholder], + }); + } } - }); - - // re-export all split files - if (plugin.config.groupByTag && plugin.config.exportFromIndex) { - const indexFile = plugin.createFile({ - case: plugin.config.case, - id: `${plugin.name}/index`, - path: `${plugin.output}/index`, - }); + } - files.forEach((_, fileId) => { - if (fileId !== plugin.name) { - const tag = fileId.split('/').pop()!; - indexFile.add( - tsc.exportAllDeclaration({ - module: `./${tag}`, - }), - ); - } - }); + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); } }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts b/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts index 2209a813a..44df4aaff 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts @@ -1,257 +1,266 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import type { Expression } from 'typescript'; -import { clientApi } from '../../../generate/client'; -import type { GeneratedFile } from '../../../generate/file'; import { hasOperationDataRequired } from '../../../ir/operation'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { type Property, tsc } from '../../../tsc'; -import { getClientBaseUrlKey } from '../../@hey-api/client-core/utils'; +import { + getClientBaseUrlKey, + getClientPlugin, +} from '../../@hey-api/client-core/utils'; import type { PiniaColadaPlugin } from './types'; -import { useTypeData } from './utils'; +import { useTypeData } from './useType'; -const createQueryKeyFn = 'createQueryKey'; -const queryKeyName = 'QueryKey'; const TOptionsType = 'TOptions'; const optionsIdentifier = tsc.identifier({ text: 'options' }); export const createQueryKeyFunction = ({ - file, plugin, }: { - file: GeneratedFile; plugin: PiniaColadaPlugin['Instance']; }) => { - const identifierCreateQueryKey = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/pinia-colada-create-query-key/${createQueryKeyFn}`, - case: plugin.config.case, - create: true, - namespace: 'value', - }); + const f = plugin.gen.ensureFile(plugin.output); - if (identifierCreateQueryKey.name) { - const returnType = tsc.indexedAccessTypeNode({ - indexType: tsc.literalTypeNode({ - literal: tsc.ots.number(0), - }), - objectType: tsc.typeReferenceNode({ - typeArguments: [tsc.typeReferenceNode({ typeName: TOptionsType })], - typeName: queryKeyName, + const symbolCreateQueryKey = f + .ensureSymbol({ selector: plugin.api.getSelector('createQueryKey') }) + .update({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'createQueryKey', }), }); + const symbolQueryKeyType = f.ensureSymbol({ + selector: plugin.api.getSelector('QueryKey'), + }); - const baseUrlKey = getClientBaseUrlKey(plugin.context.config); + const returnType = tsc.indexedAccessTypeNode({ + indexType: tsc.literalTypeNode({ + literal: tsc.ots.number(0), + }), + objectType: tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: TOptionsType })], + typeName: symbolQueryKeyType.placeholder, + }), + }); + + const baseUrlKey = getClientBaseUrlKey(plugin.context.config); - const fn = tsc.constVariable({ - expression: tsc.arrowFunction({ - multiLine: true, - parameters: [ - { - name: 'id', - type: tsc.typeReferenceNode({ typeName: 'string' }), - }, - { - isRequired: false, - name: 'options', - type: tsc.typeReferenceNode({ typeName: TOptionsType }), - }, - { - isRequired: false, - name: 'tags', - type: tsc.typeReferenceNode({ typeName: 'ReadonlyArray' }), - }, - ], - returnType: tsc.typeTupleNode({ - types: [returnType], + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + const client = getClientPlugin(plugin.context.config); + let symbolClient: ICodegenSymbolOut | undefined; + if (client.api && 'getSelector' in client.api) { + symbolClient = plugin.gen.selectSymbolFirst( + // @ts-expect-error + client.api.getSelector('client'), + ); + } + + const fn = tsc.constVariable({ + expression: tsc.arrowFunction({ + multiLine: true, + parameters: [ + { + name: 'id', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + isRequired: false, + name: 'options', + type: tsc.typeReferenceNode({ typeName: TOptionsType }), + }, + { + isRequired: false, + name: 'tags', + type: tsc.typeReferenceNode({ typeName: 'ReadonlyArray' }), + }, + ], + returnType: tsc.typeTupleNode({ + types: [returnType], + }), + statements: [ + tsc.constVariable({ + assertion: returnType, + expression: tsc.objectExpression({ + multiLine: false, + obj: [ + { + key: '_id', + value: tsc.identifier({ text: 'id' }), + }, + { + key: baseUrlKey, + value: tsc.identifier({ + text: `options?.${baseUrlKey} || (options?.client ?? ${symbolClient?.placeholder}).getConfig().${baseUrlKey}`, + }), + }, + ], + }), + name: 'params', + typeName: returnType, }), - statements: [ - tsc.constVariable({ - assertion: returnType, - expression: tsc.objectExpression({ - multiLine: false, - obj: [ - { - key: '_id', - value: tsc.identifier({ text: 'id' }), - }, - { - key: baseUrlKey, - value: tsc.identifier({ - text: `options?.${baseUrlKey} || (options?.client ?? _heyApiClient).getConfig().${baseUrlKey}`, + tsc.ifStatement({ + expression: tsc.identifier({ text: 'tags' }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'tags', }), - }, - ], - }), - name: 'params', - typeName: returnType, - }), - tsc.ifStatement({ - expression: tsc.identifier({ text: 'tags' }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'tags', - }), - right: tsc.asExpression({ - expression: tsc.asExpression({ - expression: tsc.identifier({ text: 'tags' }), - type: tsc.keywordTypeNode({ keyword: 'unknown' }), - }), - type: tsc.keywordTypeNode({ keyword: 'undefined' }), + right: tsc.asExpression({ + expression: tsc.asExpression({ + expression: tsc.identifier({ text: 'tags' }), + type: tsc.keywordTypeNode({ keyword: 'unknown' }), }), + type: tsc.keywordTypeNode({ keyword: 'undefined' }), }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'body' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'body', - }), - right: tsc.propertyAccessExpression({ - expression: 'options', - name: 'body', - }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'body' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'body', + }), + right: tsc.propertyAccessExpression({ + expression: 'options', + name: 'body', }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'headers' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'headers', - }), - right: tsc.asExpression({ - expression: tsc.asExpression({ - expression: tsc.propertyAccessExpression({ - expression: 'options', - name: 'headers', - }), - type: tsc.keywordTypeNode({ keyword: 'unknown' }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'headers' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'headers', + }), + right: tsc.asExpression({ + expression: tsc.asExpression({ + expression: tsc.propertyAccessExpression({ + expression: 'options', + name: 'headers', }), - type: tsc.keywordTypeNode({ keyword: 'undefined' }), + type: tsc.keywordTypeNode({ keyword: 'unknown' }), }), + type: tsc.keywordTypeNode({ keyword: 'undefined' }), }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'path' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'path', - }), - right: tsc.propertyAccessExpression({ - expression: 'options', - name: 'path', - }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'path' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'path', + }), + right: tsc.propertyAccessExpression({ + expression: 'options', + name: 'path', }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'query' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'query', - }), - right: tsc.asExpression({ - expression: tsc.asExpression({ - expression: tsc.propertyAccessExpression({ - expression: 'options', - name: 'query', - }), - type: tsc.keywordTypeNode({ keyword: 'unknown' }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'query' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'query', + }), + right: tsc.asExpression({ + expression: tsc.asExpression({ + expression: tsc.propertyAccessExpression({ + expression: 'options', + name: 'query', }), - type: tsc.keywordTypeNode({ keyword: 'undefined' }), + type: tsc.keywordTypeNode({ keyword: 'unknown' }), }), + type: tsc.keywordTypeNode({ keyword: 'undefined' }), }), }), - ], - }), + }), + ], }), - tsc.returnStatement({ - expression: tsc.arrayLiteralExpression({ - elements: [tsc.identifier({ text: 'params' })], - }), + }), + tsc.returnStatement({ + expression: tsc.arrayLiteralExpression({ + elements: [tsc.identifier({ text: 'params' })], }), - ], - types: [ - { - extends: tsc.typeReferenceNode({ - typeName: tsc.identifier({ - text: clientApi.Options.name, - }), - }), - name: TOptionsType, - }, - ], - }), - name: identifierCreateQueryKey.name, - }); - file.add(fn); - } + }), + ], + types: [ + { + extends: tsc.typeReferenceNode({ + typeName: tsc.identifier({ text: symbolOptions.placeholder }), + }), + name: TOptionsType, + }, + ], + }), + name: symbolCreateQueryKey.placeholder, + }); + symbolCreateQueryKey.update({ value: fn }); }; const createQueryKeyLiteral = ({ - file, id, operation, plugin, }: { - file: GeneratedFile; id: string; operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; }) => { - const identifierCreateQueryKey = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/pinia-colada-create-query-key/${createQueryKeyFn}`, - case: plugin.config.case, - namespace: 'value', - }); + const f = plugin.gen.ensureFile(plugin.output); const config = plugin.config.queryKeys; let tagsExpression: Expression | undefined; @@ -261,58 +270,68 @@ const createQueryKeyLiteral = ({ }); } + const symbolCreateQueryKey = f.ensureSymbol({ + selector: plugin.api.getSelector('createQueryKey'), + }); const createQueryKeyCallExpression = tsc.callExpression({ - functionName: identifierCreateQueryKey.name || '', + functionName: symbolCreateQueryKey.placeholder, parameters: [tsc.ots.string(id), 'options', tagsExpression], }); return createQueryKeyCallExpression; }; export const createQueryKeyType = ({ - file, plugin, }: { - file: GeneratedFile; plugin: PiniaColadaPlugin['Instance']; }) => { - file.import({ - asType: true, - module: plugin.name, - name: '_JSONValue', + const f = plugin.gen.ensureFile(plugin.output); + + const symbolJsonValue = f + .ensureSymbol({ selector: plugin.api.getSelector('_JSONValue') }) + .update({ name: '_JSONValue' }); + f.addImport({ + from: plugin.name, + typeNames: [symbolJsonValue.placeholder], }); const properties: Array = [ { name: '_id', - type: tsc.keywordTypeNode({ - keyword: 'string', - }), + type: tsc.keywordTypeNode({ keyword: 'string' }), }, { isRequired: false, name: getClientBaseUrlKey(plugin.context.config), - type: tsc.typeReferenceNode({ typeName: '_JSONValue' }), + type: tsc.typeReferenceNode({ typeName: symbolJsonValue.placeholder }), }, { isRequired: false, name: 'headers', - type: tsc.typeReferenceNode({ typeName: '_JSONValue' }), + type: tsc.typeReferenceNode({ typeName: symbolJsonValue.placeholder }), }, { isRequired: false, name: 'query', - type: tsc.typeReferenceNode({ typeName: '_JSONValue' }), + type: tsc.typeReferenceNode({ typeName: symbolJsonValue.placeholder }), }, { isRequired: false, name: 'tags', - type: tsc.typeReferenceNode({ typeName: '_JSONValue' }), + type: tsc.typeReferenceNode({ typeName: symbolJsonValue.placeholder }), }, ]; + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + const symbolQueryKeyType = f + .ensureSymbol({ selector: plugin.api.getSelector('QueryKey') }) + .update({ name: 'QueryKey' }); const queryKeyType = tsc.typeAliasDeclaration({ exportType: true, - name: queryKeyName, + name: symbolQueryKeyType.placeholder, type: tsc.typeTupleNode({ types: [ tsc.typeIntersectionNode({ @@ -331,35 +350,25 @@ export const createQueryKeyType = ({ typeParameters: [ { extends: tsc.typeReferenceNode({ - typeName: tsc.identifier({ - text: clientApi.Options.name, - }), + typeName: tsc.identifier({ text: symbolOptions.placeholder }), }), name: TOptionsType, }, ], }); - file.add(queryKeyType); + symbolQueryKeyType.update({ value: queryKeyType }); }; export const queryKeyStatement = ({ - file, operation, plugin, + symbol, }: { - file: GeneratedFile; operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; + symbol: ICodegenSymbolOut; }) => { - const typeData = useTypeData({ file, operation, plugin }); - const identifier = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/pinia-colada-query-key/${operation.id}`, - case: plugin.config.queryKeys.case, - create: true, - nameTransformer: plugin.config.queryKeys.name, - namespace: 'value', - }); + const typeData = useTypeData({ operation, plugin }); const statement = tsc.constVariable({ exportConst: true, expression: tsc.arrowFunction({ @@ -371,13 +380,12 @@ export const queryKeyStatement = ({ }, ], statements: createQueryKeyLiteral({ - file, id: operation.id, operation, plugin, }), }), - name: identifier.name || '', + name: symbol.placeholder, }); return statement; }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts b/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts index 78bf9fe0b..7c47259d3 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts @@ -1,7 +1,7 @@ import type ts from 'typescript'; -import type { GeneratedFile } from '../../../generate/file'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createOperationComment, @@ -16,32 +16,27 @@ import { } from './queryKey'; import type { PluginState } from './state'; import type { PiniaColadaPlugin } from './types'; -import { useTypeData, useTypeError, useTypeResponse } from './utils'; +import { useTypeData, useTypeError, useTypeResponse } from './useType'; -const queryOptionsType = 'UseQueryOptions'; +const fnOptions = 'context'; const optionsParamName = 'options'; export const createQueryOptions = ({ - file, operation, plugin, queryFn, state, }: { - file: GeneratedFile; operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; queryFn: string; state: PluginState; }): void => { - if ( - !plugin.config.queryOptions.enabled || - !plugin.hooks.operation.isQuery(operation) || - hasOperationSse({ operation }) - ) { + if (hasOperationSse({ operation })) { return; } + const f = plugin.gen.ensureFile(plugin.output); const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, @@ -51,48 +46,39 @@ export const createQueryOptions = ({ state.hasQueries = true; if (!state.hasCreateQueryKeyParamsFunction) { - createQueryKeyType({ file, plugin }); - createQueryKeyFunction({ file, plugin }); + createQueryKeyType({ plugin }); + createQueryKeyFunction({ plugin }); state.hasCreateQueryKeyParamsFunction = true; } - - file.import({ - asType: true, - module: plugin.name, - name: queryOptionsType, - }); } + const symbolUseQueryOptions = f.ensureSymbol({ + name: 'UseQueryOptions', + selector: plugin.api.getSelector('UseQueryOptions'), + }); + f.addImport({ + from: plugin.name, + typeNames: [symbolUseQueryOptions.name], + }); + state.hasUsedQueryFn = true; + const symbolQueryKey = f.addSymbol({ + name: buildName({ + config: plugin.config.queryKeys, + name: operation.id, + }), + }); const node = queryKeyStatement({ - file, operation, plugin, + symbol: symbolQueryKey, }); - file.add(node); - - const typeData = useTypeData({ file, operation, plugin }); - const typeError = useTypeError({ file, operation, plugin }); - const typeResponse = useTypeResponse({ file, operation, plugin }); - - const identifierQueryOptions = file.identifier({ - $ref: `#/pinia-colada-query-options/${operation.id}`, - case: plugin.config.queryOptions.case, - create: true, - nameTransformer: plugin.config.queryOptions.name, - namespace: 'value', - }); - - const fnOptions = 'context'; + symbolQueryKey.update({ value: node }); - const identifierQueryKey = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/pinia-colada-query-key/${operation.id}`, - case: plugin.config.queryKeys.case, - nameTransformer: plugin.config.queryKeys.name, - namespace: 'value', - }); + const typeData = useTypeData({ operation, plugin }); + const typeError = useTypeError({ operation, plugin }); + const typeResponse = useTypeResponse({ operation, plugin }); const awaitSdkExpression = tsc.awaitExpression({ expression: tsc.callExpression({ @@ -119,7 +105,7 @@ export const createQueryOptions = ({ const statements: Array = []; - if (plugin.getPlugin('@hey-api/sdk')?.config.responseStyle === 'data') { + if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') { statements.push( tsc.returnVariable({ expression: awaitSdkExpression, @@ -142,7 +128,7 @@ export const createQueryOptions = ({ { key: 'key', value: tsc.callExpression({ - functionName: identifierQueryKey.name || '', + functionName: symbolQueryKey.placeholder, parameters: [optionsParamName], }), }, @@ -170,6 +156,16 @@ export const createQueryOptions = ({ }); } + const symbolQueryOptionsFn = f + .ensureSymbol({ + selector: plugin.api.getSelector('queryOptionsFn', operation.id), + }) + .update({ + name: buildName({ + config: plugin.config.queryOptions, + name: operation.id, + }), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) @@ -184,7 +180,7 @@ export const createQueryOptions = ({ }, ], // TODO: better types syntax - returnType: `${queryOptionsType}<${typeResponse}, ${typeError.name}>`, + returnType: `${symbolUseQueryOptions.placeholder}<${typeResponse}, ${typeError}>`, statements: [ tsc.returnStatement({ expression: tsc.objectExpression({ @@ -193,8 +189,7 @@ export const createQueryOptions = ({ }), ], }), - name: identifierQueryOptions.name || '', + name: symbolQueryOptionsFn.placeholder, }); - - file.add(statement); + symbolQueryOptionsFn.update({ value: statement }); }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/state.ts b/packages/openapi-ts/src/plugins/@pinia/colada/state.ts index 033f09d3b..cb952f3e6 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/state.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/state.ts @@ -4,10 +4,3 @@ export interface PluginState { hasQueries: boolean; hasUsedQueryFn: boolean; } - -export const getInitialState = (): PluginState => ({ - hasCreateQueryKeyParamsFunction: false, - hasMutations: false, - hasQueries: false, - hasUsedQueryFn: false, -}); diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts b/packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts index f40f69de3..26ed75c91 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts @@ -1,6 +1,7 @@ import type { IR } from '../../../ir/types'; import type { StringCase, StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@pinia/colada'> & Plugin.Hooks & { @@ -28,14 +29,6 @@ export type UserConfig = Plugin.Name<'@pinia/colada'> & * @default false */ exportFromIndex?: boolean; - /** - * Group generated files by OpenAPI tags. When enabled, operations will be organized - * into separate files based on their tags, allowing for better code organization - * and tree-shaking. - * - * @default false - */ - groupByTag?: boolean; /** * Configuration for generated mutation options helpers. * @@ -225,14 +218,6 @@ export type Config = Plugin.Name<'@pinia/colada'> & * @default false */ exportFromIndex: boolean; - /** - * Group generated files by OpenAPI tags. When enabled, operations will be organized - * into separate files based on their tags, allowing for better code organization - * and tree-shaking. - * - * @default false - */ - groupByTag: boolean; /** * Resolved configuration for generated mutation options helpers. */ @@ -374,4 +359,4 @@ export type Config = Plugin.Name<'@pinia/colada'> & }; }; -export type PiniaColadaPlugin = DefinePlugin; +export type PiniaColadaPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/useType.ts b/packages/openapi-ts/src/plugins/@pinia/colada/useType.ts new file mode 100644 index 000000000..82eac2291 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@pinia/colada/useType.ts @@ -0,0 +1,80 @@ +import type { IR } from '../../../ir/types'; +import { getClientPlugin } from '../../@hey-api/client-core/utils'; +import { operationOptionsType } from '../../@hey-api/sdk/operation'; +import type { PiniaColadaPlugin } from './types'; + +export const useTypeData = ({ + operation, + plugin, +}: { + operation: IR.OperationObject; + plugin: PiniaColadaPlugin['Instance']; +}): string => { + const f = plugin.gen.ensureFile(plugin.output); + const pluginSdk = plugin.getPluginOrThrow('@hey-api/sdk'); + const typeData = operationOptionsType({ + file: f, + operation, + plugin: pluginSdk, + }); + return typeData; +}; + +export const useTypeError = ({ + operation, + plugin, +}: { + operation: IR.OperationObject; + plugin: PiniaColadaPlugin['Instance']; +}): string => { + const f = plugin.gen.ensureFile(plugin.output); + const client = getClientPlugin(plugin.context.config); + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + + const symbolErrorType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('error', operation.id), + ); + if (symbolErrorType) { + f.addImport({ + from: symbolErrorType.file, + typeNames: [symbolErrorType.placeholder], + }); + } + + let typeErrorName: string | undefined = symbolErrorType?.placeholder; + if (!typeErrorName) { + typeErrorName = 'Error'; + } + if (client.name === '@hey-api/client-axios') { + const symbol = f + .ensureSymbol({ selector: plugin.api.getSelector('AxiosError') }) + .update({ name: 'AxiosError' }); + f.addImport({ + from: 'axios', + typeNames: [symbol.placeholder], + }); + typeErrorName = `${symbol.placeholder}<${typeErrorName}>`; + } + return typeErrorName; +}; + +export const useTypeResponse = ({ + operation, + plugin, +}: { + operation: IR.OperationObject; + plugin: PiniaColadaPlugin['Instance']; +}): string => { + const f = plugin.gen.ensureFile(plugin.output); + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + const symbolResponseType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('response', operation.id), + ); + if (symbolResponseType) { + f.addImport({ + from: symbolResponseType.file, + typeNames: [symbolResponseType.placeholder], + }); + } + return symbolResponseType?.placeholder || 'unknown'; +}; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/utils.ts b/packages/openapi-ts/src/plugins/@pinia/colada/utils.ts deleted file mode 100644 index 1856d8aab..000000000 --- a/packages/openapi-ts/src/plugins/@pinia/colada/utils.ts +++ /dev/null @@ -1,130 +0,0 @@ -import { clientApi } from '../../../generate/client'; -import type { GeneratedFile } from '../../../generate/file'; -import type { IR } from '../../../ir/types'; -import type { ImportExportItemObject } from '../../../tsc/utils'; -import { getClientPlugin } from '../../@hey-api/client-core/utils'; -import { sdkId } from '../../@hey-api/sdk/constants'; -import { operationOptionsType } from '../../@hey-api/sdk/operation'; -import { typesId } from '../../@hey-api/typescript/ref'; -import { getInitialState, type PluginState } from './state'; -import type { PiniaColadaPlugin } from './types'; - -export const getFileForOperation = ({ - files, - operation, - plugin, - states, -}: { - files: Map; - operation: IR.OperationObject; - plugin: PiniaColadaPlugin['Instance']; - states: Map; -}) => { - let tag = ''; - if (plugin.config.groupByTag) { - tag = operation.tags?.[0] || 'default'; - } - - const fileId = tag ? `${plugin.name}/${tag}` : plugin.name; - - if (!files.has(fileId)) { - const filePath = tag ? `${plugin.output}/${tag}` : plugin.output; - const file = plugin.createFile({ - case: plugin.config.case, - id: fileId, - path: filePath, - }); - files.set(fileId, file); - states.set(fileId, getInitialState()); - // import Options type from SDK - file.import({ - ...clientApi.Options, - module: file.relativePathToFile({ context: plugin.context, id: sdkId }), - }); - } - - return { - file: files.get(fileId)!, - state: states.get(fileId)!, - }; -}; - -export const useTypeData = ({ - file, - operation, - plugin, -}: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: PiniaColadaPlugin['Instance']; -}) => { - const pluginSdk = plugin.getPlugin('@hey-api/sdk')!; - const typeData = operationOptionsType({ file, operation, plugin: pluginSdk }); - return typeData; -}; - -export const useTypeError = ({ - file, - operation, - plugin, -}: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: PiniaColadaPlugin['Instance']; -}) => { - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const errorImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'error' }), - ), - }); - let typeError: ImportExportItemObject = { - asType: true, - name: errorImport.name || '', - }; - if (!typeError.name) { - typeError = { - asType: true, - name: 'Error', - }; - } - const client = getClientPlugin(plugin.context.config); - if (client.name === '@hey-api/client-axios') { - const axiosError = file.import({ - asType: true, - module: 'axios', - name: 'AxiosError', - }); - typeError = { - ...axiosError, - name: `${axiosError.name}<${typeError.name}>`, - }; - } - return typeError; -}; - -export const useTypeResponse = ({ - file, - operation, - plugin, -}: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: PiniaColadaPlugin['Instance']; -}) => { - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const responseImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'response' }), - ), - }); - - const typeResponse = responseImport.name || 'unknown'; - return typeResponse; -}; diff --git a/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/api.ts b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/api.ts new file mode 100644 index 000000000..357aff01d --- /dev/null +++ b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/api.ts @@ -0,0 +1,48 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | 'AxiosError' + | 'createInfiniteParams' + | 'createQueryKey' + | 'DefaultError' + | 'infiniteQueryOptions' + | 'InfiniteData' + | 'MutationOptions' + | 'queryOptions' + | 'queryOptionsFn' + | 'QueryKey' + | 'useQuery'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `AxiosError`: never + * - `createInfiniteParams`: never + * - `createQueryKey`: never + * - `DefaultError`: never + * - `infiniteQueryOptions`: never + * - `InfiniteData`: never + * - `MutationOptions`: never + * - `queryOptions`: never + * - `queryOptionsFn`: `operation.id` string + * - `QueryKey`: never + * - `useQuery`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor( + public meta: Plugin.Name<'@tanstack/angular-query-experimental'>, + ) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts index 4086f0ed2..42a1d2f05 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/config.ts @@ -1,9 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; import { handler } from '../query-core/plugin'; import { handlerLegacy } from '../query-core/plugin-legacy'; +import { Api } from './api'; import type { TanStackAngularQueryPlugin } from './types'; export const defaultConfig: TanStackAngularQueryPlugin['Config'] = { + api: new Api({ + name: '@tanstack/angular-query-experimental', + }), config: { case: 'camelCase', comments: true, diff --git a/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts index 4857dcf9e..96fe6a7ff 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/types.d.ts @@ -1,6 +1,7 @@ import type { IR } from '../../../ir/types'; import type { StringCase, StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@tanstack/angular-query-experimental'> & Plugin.Hooks & { @@ -555,4 +556,4 @@ export type Config = Plugin.Name<'@tanstack/angular-query-experimental'> & }; }; -export type TanStackAngularQueryPlugin = DefinePlugin; +export type TanStackAngularQueryPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts index fd7e69fc7..985a2f4c4 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts @@ -1,8 +1,8 @@ import ts from 'typescript'; -import { clientApi } from '../../../generate/client'; import { operationPagination } from '../../../ir/operation'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { tsNodeToString } from '../../../tsc/utils'; import { @@ -13,29 +13,28 @@ import { handleMeta } from './meta'; import { createQueryKeyFunction, createQueryKeyType, - queryKeyName, queryKeyStatement, } from './queryKey'; import type { PluginInstance, PluginState } from './types'; import { useTypeData, useTypeError, useTypeResponse } from './useType'; -const createInfiniteParamsFn = 'createInfiniteParams'; -const infiniteQueryOptionsFn = 'infiniteQueryOptions'; - const createInfiniteParamsFunction = ({ plugin, }: { plugin: PluginInstance; }) => { - const file = plugin.context.file({ id: plugin.name })!; + const f = plugin.gen.ensureFile(plugin.output); - const identifierCreateInfiniteParams = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-create-infinite-params/${createInfiniteParamsFn}`, - case: plugin.config.case, - create: true, - namespace: 'value', - }); + const symbolCreateInfiniteParams = f + .ensureSymbol({ selector: plugin.api.getSelector('createInfiniteParams') }) + .update({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'createInfiniteParams', + }), + }); const fn = tsc.constVariable({ expression: tsc.arrowFunction({ @@ -43,9 +42,7 @@ const createInfiniteParamsFunction = ({ parameters: [ { name: 'queryKey', - type: tsc.typeReferenceNode({ - typeName: `QueryKey<${clientApi.Options.name}>`, - }), + type: tsc.typeReferenceNode({ typeName: 'QueryKey' }), }, { name: 'page', @@ -212,16 +209,16 @@ const createInfiniteParamsFunction = ({ { extends: tsc.typeReferenceNode({ typeName: tsc.identifier({ - text: `Pick[0], 'body' | 'headers' | 'path' | 'query'>`, + text: "Pick[0], 'body' | 'headers' | 'path' | 'query'>", }), }), name: 'K', }, ], }), - name: identifierCreateInfiniteParams.name || '', + name: symbolCreateInfiniteParams.placeholder, }); - file.add(fn); + symbolCreateInfiniteParams.update({ value: fn }); }; export const createInfiniteQueryOptions = ({ @@ -244,7 +241,7 @@ export const createInfiniteQueryOptions = ({ return; } - const file = plugin.context.file({ id: plugin.name })!; + const f = plugin.gen.ensureFile(plugin.output); const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, @@ -263,28 +260,32 @@ export const createInfiniteQueryOptions = ({ createInfiniteParamsFunction({ plugin }); state.hasCreateInfiniteParamsFunction = true; } - - file.import({ - module: plugin.name, - name: infiniteQueryOptionsFn, - }); - - state.typeInfiniteData = file.import({ - asType: true, - module: plugin.name, - name: 'InfiniteData', - }); } + const symbolInfiniteQueryOptions = f + .ensureSymbol({ selector: plugin.api.getSelector('infiniteQueryOptions') }) + .update({ name: 'infiniteQueryOptions' }); + const symbolInfiniteDataType = f + .ensureSymbol({ selector: plugin.api.getSelector('InfiniteData') }) + .update({ name: 'InfiniteData' }); + f.addImport({ + from: plugin.name, + names: [symbolInfiniteQueryOptions.name], + typeNames: [symbolInfiniteDataType.name], + }); + state.hasUsedQueryFn = true; const typeData = useTypeData({ operation, plugin }); const typeError = useTypeError({ operation, plugin }); const typeResponse = useTypeResponse({ operation, plugin }); - const typeQueryKey = `${queryKeyName}<${typeData}>`; + const symbolQueryKeyType = f.ensureSymbol({ + selector: plugin.api.getSelector('QueryKey'), + }); + const typeQueryKey = `${symbolQueryKeyType.placeholder}<${typeData}>`; const typePageObjectParam = `Pick<${typeQueryKey}[0], 'body' | 'headers' | 'path' | 'query'>`; - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); // TODO: parser - this is a bit clunky, need to compile type to string because // `tsc.returnFunctionCall()` accepts only strings, should be cleaned up const typescriptState = { @@ -300,21 +301,20 @@ export const createInfiniteQueryOptions = ({ unescape: true, })} | ${typePageObjectParam}`; + const symbolInfiniteQueryKey = f.addSymbol({ + name: buildName({ + config: plugin.config.infiniteQueryKeys, + name: operation.id, + }), + }); const node = queryKeyStatement({ isInfinite: true, operation, plugin, + symbol: symbolInfiniteQueryKey, typeQueryKey, }); - file.add(node); - - const identifierInfiniteQueryKey = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-infinite-query-key/${operation.id}`, - case: plugin.config.infiniteQueryKeys.case, - nameTransformer: plugin.config.infiniteQueryKeys.name, - namespace: 'value', - }); + symbolInfiniteQueryKey.update({ value: node }); const awaitSdkExpression = tsc.awaitExpression({ expression: tsc.callExpression({ @@ -346,11 +346,8 @@ export const createInfiniteQueryOptions = ({ }), }); - const identifierCreateInfiniteParams = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-create-infinite-params/${createInfiniteParamsFn}`, - case: plugin.config.case, - namespace: 'value', + const symbolCreateInfiniteParams = f.ensureSymbol({ + selector: plugin.api.getSelector('createInfiniteParams'), }); const statements: Array = [ @@ -397,14 +394,14 @@ export const createInfiniteQueryOptions = ({ }), tsc.constVariable({ expression: tsc.callExpression({ - functionName: identifierCreateInfiniteParams.name || '', + functionName: symbolCreateInfiniteParams.placeholder, parameters: ['queryKey', 'page'], }), name: 'params', }), ]; - if (plugin.getPlugin('@hey-api/sdk')?.config.responseStyle === 'data') { + if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') { statements.push( tsc.returnVariable({ expression: awaitSdkExpression, @@ -423,15 +420,6 @@ export const createInfiniteQueryOptions = ({ ); } - const identifierInfiniteQueryOptions = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-infinite-query-options/${operation.id}`, - case: plugin.config.infiniteQueryOptions.case, - create: true, - nameTransformer: plugin.config.infiniteQueryOptions.name, - namespace: 'value', - }); - const infiniteQueryOptionsObj: Array<{ key: string; value: ts.Expression }> = [ { @@ -460,7 +448,7 @@ export const createInfiniteQueryOptions = ({ { key: 'queryKey', value: tsc.callExpression({ - functionName: identifierInfiniteQueryKey.name || '', + functionName: symbolInfiniteQueryKey.placeholder, parameters: ['options'], }), }, @@ -475,6 +463,12 @@ export const createInfiniteQueryOptions = ({ }); } + const symbolInfiniteQueryOptionsFn = f.addSymbol({ + name: buildName({ + config: plugin.config.infiniteQueryOptions, + name: operation.id, + }), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) @@ -501,20 +495,19 @@ export const createInfiniteQueryOptions = ({ obj: infiniteQueryOptionsObj, }), ], - name: infiniteQueryOptionsFn, + name: symbolInfiniteQueryOptions.placeholder, // TODO: better types syntax types: [ typeResponse, - typeError.name || 'unknown', - `${typeof state.typeInfiniteData === 'string' ? state.typeInfiniteData : state.typeInfiniteData.name}<${typeResponse}>`, + typeError || 'unknown', + `${symbolInfiniteDataType.placeholder}<${typeResponse}>`, typeQueryKey, typePageParam, ], }), ], }), - name: identifierInfiniteQueryOptions.name || '', + name: symbolInfiniteQueryOptionsFn.placeholder, }); - file.add(statement); - return; + symbolInfiniteQueryOptionsFn.update({ value: statement }); }; diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/mutationOptions.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/mutationOptions.ts index b718e10d8..02f2ea0e1 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/mutationOptions.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/mutationOptions.ts @@ -1,14 +1,13 @@ import type ts from 'typescript'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createOperationComment } from '../../shared/utils/operation'; import { handleMeta } from './meta'; import type { PluginInstance, PluginState } from './types'; import { useTypeData, useTypeError, useTypeResponse } from './useType'; -const mutationOptionsFn = 'mutationOptions'; - export const createMutationOptions = ({ operation, plugin, @@ -27,25 +26,28 @@ export const createMutationOptions = ({ ? 'MutationOptions' : 'UseMutationOptions'; - const file = plugin.context.file({ id: plugin.name })!; + const f = plugin.gen.ensureFile(plugin.output); if (!state.hasMutations) { state.hasMutations = true; - - file.import({ - asType: true, - module: plugin.name, - name: mutationsType, - }); } + const symbolMutationOptionsType = f.ensureSymbol({ + name: mutationsType, + selector: plugin.api.getSelector('MutationOptions'), + }); + f.addImport({ + from: plugin.name, + typeNames: [symbolMutationOptionsType.name], + }); + state.hasUsedQueryFn = true; const typeData = useTypeData({ operation, plugin }); const typeError = useTypeError({ operation, plugin }); const typeResponse = useTypeResponse({ operation, plugin }); // TODO: better types syntax - const mutationType = `${mutationsType}<${typeResponse}, ${typeError.name}, ${typeData}>`; + const mutationType = `${symbolMutationOptionsType.placeholder}<${typeResponse}, ${typeError}, ${typeData}>`; const fnOptions = 'fnOptions'; @@ -74,7 +76,7 @@ export const createMutationOptions = ({ const statements: Array = []; - if (plugin.getPlugin('@hey-api/sdk')?.config.responseStyle === 'data') { + if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') { statements.push( tsc.returnVariable({ expression: awaitSdkExpression, @@ -93,15 +95,6 @@ export const createMutationOptions = ({ ); } - const identifier = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-mutation-options/${operation.id}`, - case: plugin.config.mutationOptions.case, - create: true, - nameTransformer: plugin.config.mutationOptions.name, - namespace: 'value', - }); - const mutationOptionsObj: Array<{ key: string; value: ts.Expression }> = [ { key: 'mutationFn', @@ -127,6 +120,7 @@ export const createMutationOptions = ({ }); } + const mutationOptionsFn = 'mutationOptions'; const expression = tsc.arrowFunction({ parameters: [ { @@ -149,13 +143,19 @@ export const createMutationOptions = ({ }), ], }); + const symbolMutationOptions = f.addSymbol({ + name: buildName({ + config: plugin.config.mutationOptions, + name: operation.id, + }), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) : undefined, exportConst: true, expression, - name: identifier.name || '', + name: symbolMutationOptions.placeholder, }); - file.add(statement); + symbolMutationOptions.update({ value: statement }); }; diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin-legacy.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin-legacy.ts index b9ff1c115..5825d1a46 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin-legacy.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin-legacy.ts @@ -1,6 +1,6 @@ import ts from 'typescript'; -import { clientApi, clientModulePath } from '../../../generate/client'; +import { clientModulePath } from '../../../generate/client'; import { relativeModulePath } from '../../../generate/utils'; import { createOperationKey } from '../../../ir/operation'; import { getPaginationKeywordsRegExp } from '../../../ir/pagination'; @@ -114,7 +114,7 @@ const createInfiniteParamsFunction = ({ parameters: [ { name: 'queryKey', - type: tsc.typeNode(`QueryKey<${clientApi.OptionsLegacyParser.name}>`), + type: tsc.typeNode('QueryKey'), }, { name: 'page', @@ -268,7 +268,7 @@ const createInfiniteParamsFunction = ({ { extends: tsc.typeReferenceNode({ typeName: tsc.identifier({ - text: `Pick[0], 'body' | 'headers' | 'path' | 'query'>`, + text: "Pick[0], 'body' | 'headers' | 'path' | 'query'>", }), }), name: 'K', @@ -445,9 +445,7 @@ const createQueryKeyFunction = ({ file }: { file: Files[keyof Files] }) => { types: [ { extends: tsc.typeReferenceNode({ - typeName: tsc.identifier({ - text: clientApi.OptionsLegacyParser.name, - }), + typeName: tsc.identifier({ text: 'OptionsLegacyParser' }), }), name: TOptionsType, }, @@ -495,9 +493,7 @@ const createQueryKeyType = ({ file }: { file: Files[keyof Files] }) => { typeParameters: [ { extends: tsc.typeReferenceNode({ - typeName: tsc.identifier({ - text: clientApi.OptionsLegacyParser.name, - }), + typeName: tsc.identifier({ text: 'OptionsLegacyParser' }), }), name: TOptionsType, }, @@ -682,8 +678,9 @@ export const handlerLegacy = ({ const file = files[plugin.name]!; file.import({ - ...clientApi.OptionsLegacyParser, + asType: true, module: clientModulePath({ config, sourceOutput: plugin.output }), + name: 'OptionsLegacyParser', }); const typesModulePath = relativeModulePath({ diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts index 0d44468d4..aeea10d38 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts @@ -1,7 +1,8 @@ -import { clientApi } from '../../../generate/client'; +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; + +import { TypeScriptRenderer } from '../../../generate/renderer'; import { stringCase } from '../../../utils/stringCase'; -import { clientId } from '../../@hey-api/client-core/utils'; -import { sdkId } from '../../@hey-api/sdk/constants'; +import { getClientPlugin } from '../../@hey-api/client-core/utils'; import { operationClasses } from '../../@hey-api/sdk/operation'; import { serviceFunctionIdentifier } from '../../@hey-api/sdk/plugin-legacy'; import { createInfiniteQueryOptions } from './infiniteQueryOptions'; @@ -10,11 +11,11 @@ import { createQueryOptions } from './queryOptions'; import type { PluginHandler, PluginState } from './types'; import { createUseQuery } from './useQuery'; -export const handler = ({ plugin }: Parameters[0]) => { - const file = plugin.createFile({ - case: plugin.config.case, - id: plugin.name, - path: plugin.output, +export const handler: PluginHandler = ({ plugin }) => { + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); const state: PluginState = { @@ -27,16 +28,21 @@ export const handler = ({ plugin }: Parameters[0]) => { typeInfiniteData: undefined!, }; - file.import({ - ...clientApi.Options, - module: file.relativePathToFile({ context: plugin.context, id: sdkId }), - }); + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirst( + sdkPlugin.api.getSelector('Options'), + ); + if (symbolOptions) { + f.addImport({ + from: symbolOptions.file, + typeNames: [symbolOptions.placeholder], + }); + } plugin.forEach('operation', ({ operation }) => { state.hasUsedQueryFn = false; - const sdkPlugin = plugin.getPlugin('@hey-api/sdk'); - const classes = sdkPlugin?.config.asClass + const classes = sdkPlugin.config.asClass ? operationClasses({ context: plugin.context, operation, @@ -105,21 +111,38 @@ export const handler = ({ plugin }: Parameters[0]) => { } if (state.hasUsedQueryFn) { - file.import({ - module: file.relativePathToFile({ context: plugin.context, id: sdkId }), - name: queryFn.split('.')[0]!, - }); + // TODO: make this work with static classes + const symbolFunction = plugin.gen.selectSymbolFirst( + sdkPlugin.api.getSelector('function', operation.id), + ); + if (symbolFunction) { + f.addImport({ + from: symbolFunction.file, + names: [symbolFunction.placeholder], + }); + } } }); if (state.hasQueries || state.hasInfiniteQueries) { - file.import({ - alias: '_heyApiClient', - module: file.relativePathToFile({ - context: plugin.context, - id: clientId, - }), - name: 'client', - }); + let symbolClient: ICodegenSymbolOut | undefined; + const client = getClientPlugin(plugin.context.config); + if (client.api && 'getSelector' in client.api) { + symbolClient = plugin.gen.selectSymbolFirst( + // @ts-expect-error + client.api.getSelector('client'), + ); + if (symbolClient) { + f.addImport({ + from: symbolClient.file, + names: [symbolClient.placeholder], + }); + } + } + } + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); } }; diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts index 69ee9e6bf..329fd7fd1 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts @@ -1,15 +1,17 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import type { Expression } from 'typescript'; -import { clientApi } from '../../../generate/client'; import { hasOperationDataRequired } from '../../../ir/operation'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { type Property, tsc } from '../../../tsc'; -import { getClientBaseUrlKey } from '../../@hey-api/client-core/utils'; +import { + getClientBaseUrlKey, + getClientPlugin, +} from '../../@hey-api/client-core/utils'; import type { PluginInstance } from './types'; import { useTypeData } from './useType'; -const createQueryKeyFn = 'createQueryKey'; -export const queryKeyName = 'QueryKey'; const TOptionsType = 'TOptions'; const infiniteIdentifier = tsc.identifier({ text: 'infinite' }); @@ -20,222 +22,238 @@ export const createQueryKeyFunction = ({ }: { plugin: PluginInstance; }) => { - const file = plugin.context.file({ id: plugin.name })!; + const f = plugin.gen.ensureFile(plugin.output); - const identifierCreateQueryKey = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-create-query-key/${createQueryKeyFn}`, - case: plugin.config.case, - create: true, - namespace: 'value', - }); - - if (identifierCreateQueryKey.name) { - const returnType = tsc.indexedAccessTypeNode({ - indexType: tsc.literalTypeNode({ - literal: tsc.ots.number(0), - }), - objectType: tsc.typeReferenceNode({ - typeArguments: [tsc.typeReferenceNode({ typeName: TOptionsType })], - typeName: queryKeyName, + const symbolCreateQueryKey = f + .ensureSymbol({ selector: plugin.api.getSelector('createQueryKey') }) + .update({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'createQueryKey', }), }); + const symbolQueryKeyType = f.ensureSymbol({ + selector: plugin.api.getSelector('QueryKey'), + }); - const baseUrlKey = getClientBaseUrlKey(plugin.context.config); + const returnType = tsc.indexedAccessTypeNode({ + indexType: tsc.literalTypeNode({ + literal: tsc.ots.number(0), + }), + objectType: tsc.typeReferenceNode({ + typeArguments: [tsc.typeReferenceNode({ typeName: TOptionsType })], + typeName: symbolQueryKeyType.placeholder, + }), + }); - const fn = tsc.constVariable({ - expression: tsc.arrowFunction({ - multiLine: true, - parameters: [ - { - name: 'id', - type: tsc.typeReferenceNode({ typeName: 'string' }), - }, - { - isRequired: false, - name: 'options', - type: tsc.typeReferenceNode({ typeName: TOptionsType }), - }, - { - isRequired: false, - name: 'infinite', - type: tsc.typeReferenceNode({ typeName: 'boolean' }), - }, - { - isRequired: false, - name: 'tags', - type: tsc.typeReferenceNode({ typeName: 'ReadonlyArray' }), - }, - ], - returnType: tsc.typeTupleNode({ - types: [returnType], - }), - statements: [ - tsc.constVariable({ - assertion: returnType, - expression: tsc.objectExpression({ - multiLine: false, - obj: [ - { - key: '_id', - value: tsc.identifier({ text: 'id' }), - }, - { - key: baseUrlKey, - value: tsc.identifier({ - text: `options?.${baseUrlKey} || (options?.client ?? _heyApiClient).getConfig().${baseUrlKey}`, - }), - }, - ], - }), - name: 'params', - typeName: returnType, + const baseUrlKey = getClientBaseUrlKey(plugin.context.config); + + const client = getClientPlugin(plugin.context.config); + let symbolClient: ICodegenSymbolOut | undefined; + if (client.api && 'getSelector' in client.api) { + symbolClient = plugin.gen.selectSymbolFirst( + // @ts-expect-error + client.api.getSelector('client'), + ); + } + + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + + const fn = tsc.constVariable({ + expression: tsc.arrowFunction({ + multiLine: true, + parameters: [ + { + name: 'id', + type: tsc.typeReferenceNode({ typeName: 'string' }), + }, + { + isRequired: false, + name: 'options', + type: tsc.typeReferenceNode({ typeName: TOptionsType }), + }, + { + isRequired: false, + name: 'infinite', + type: tsc.typeReferenceNode({ typeName: 'boolean' }), + }, + { + isRequired: false, + name: 'tags', + type: tsc.typeReferenceNode({ typeName: 'ReadonlyArray' }), + }, + ], + returnType: tsc.typeTupleNode({ + types: [returnType], + }), + statements: [ + tsc.constVariable({ + assertion: returnType, + expression: tsc.objectExpression({ + multiLine: false, + obj: [ + { + key: '_id', + value: tsc.identifier({ text: 'id' }), + }, + { + key: baseUrlKey, + value: tsc.identifier({ + text: `options?.${baseUrlKey} || (options?.client ?? ${symbolClient?.placeholder}).getConfig().${baseUrlKey}`, + }), + }, + ], }), - tsc.ifStatement({ - expression: infiniteIdentifier, - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: '_infinite', - }), - right: infiniteIdentifier, + name: 'params', + typeName: returnType, + }), + tsc.ifStatement({ + expression: infiniteIdentifier, + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: '_infinite', }), + right: infiniteIdentifier, }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.identifier({ text: 'tags' }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'tags', - }), - right: tsc.identifier({ text: 'tags' }), + }), + tsc.ifStatement({ + expression: tsc.identifier({ text: 'tags' }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'tags', }), + right: tsc.identifier({ text: 'tags' }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'body' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'body', - }), - right: tsc.propertyAccessExpression({ - expression: 'options', - name: 'body', - }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'body' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'body', + }), + right: tsc.propertyAccessExpression({ + expression: 'options', + name: 'body', }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'headers' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'headers', - }), - right: tsc.propertyAccessExpression({ - expression: 'options', - name: 'headers', - }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'headers' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'headers', + }), + right: tsc.propertyAccessExpression({ + expression: 'options', + name: 'headers', }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'path' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'path', - }), - right: tsc.propertyAccessExpression({ - expression: 'options', - name: 'path', - }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'path' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'path', + }), + right: tsc.propertyAccessExpression({ + expression: 'options', + name: 'path', }), }), - ], - }), + }), + ], }), - tsc.ifStatement({ - expression: tsc.propertyAccessExpression({ - expression: optionsIdentifier, - isOptional: true, - name: tsc.identifier({ text: 'query' }), - }), - thenStatement: tsc.block({ - statements: [ - tsc.expressionToStatement({ - expression: tsc.binaryExpression({ - left: tsc.propertyAccessExpression({ - expression: 'params', - name: 'query', - }), - right: tsc.propertyAccessExpression({ - expression: 'options', - name: 'query', - }), + }), + tsc.ifStatement({ + expression: tsc.propertyAccessExpression({ + expression: optionsIdentifier, + isOptional: true, + name: tsc.identifier({ text: 'query' }), + }), + thenStatement: tsc.block({ + statements: [ + tsc.expressionToStatement({ + expression: tsc.binaryExpression({ + left: tsc.propertyAccessExpression({ + expression: 'params', + name: 'query', + }), + right: tsc.propertyAccessExpression({ + expression: 'options', + name: 'query', }), }), - ], - }), + }), + ], }), - tsc.returnStatement({ - expression: tsc.arrayLiteralExpression({ - elements: [tsc.identifier({ text: 'params' })], - }), + }), + tsc.returnStatement({ + expression: tsc.arrayLiteralExpression({ + elements: [tsc.identifier({ text: 'params' })], }), - ], - types: [ - { - extends: tsc.typeReferenceNode({ - typeName: tsc.identifier({ - text: clientApi.Options.name, - }), - }), - name: TOptionsType, - }, - ], - }), - name: identifierCreateQueryKey.name, - }); - file.add(fn); - } + }), + ], + types: [ + { + extends: tsc.typeReferenceNode({ + typeName: tsc.identifier({ text: symbolOptions.placeholder }), + }), + name: TOptionsType, + }, + ], + }), + name: symbolCreateQueryKey.placeholder, + }); + symbolCreateQueryKey.update({ value: fn }); }; const createQueryKeyLiteral = ({ @@ -249,13 +267,7 @@ const createQueryKeyLiteral = ({ operation: IR.OperationObject; plugin: PluginInstance; }) => { - const file = plugin.context.file({ id: plugin.name })!; - const identifierCreateQueryKey = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-create-query-key/${createQueryKeyFn}`, - case: plugin.config.case, - namespace: 'value', - }); + const f = plugin.gen.ensureFile(plugin.output); const config = isInfinite ? plugin.config.infiniteQueryKeys @@ -267,8 +279,11 @@ const createQueryKeyLiteral = ({ }); } + const symbolCreateQueryKey = f.ensureSymbol({ + selector: plugin.api.getSelector('createQueryKey'), + }); const createQueryKeyCallExpression = tsc.callExpression({ - functionName: identifierCreateQueryKey.name || '', + functionName: symbolCreateQueryKey.placeholder, parameters: [ tsc.ots.string(id), 'options', @@ -282,34 +297,35 @@ const createQueryKeyLiteral = ({ }; export const createQueryKeyType = ({ plugin }: { plugin: PluginInstance }) => { - const file = plugin.context.file({ id: plugin.name })!; + const f = plugin.gen.ensureFile(plugin.output); const properties: Array = [ { name: '_id', - type: tsc.keywordTypeNode({ - keyword: 'string', - }), + type: tsc.keywordTypeNode({ keyword: 'string' }), }, { isRequired: false, name: '_infinite', - type: tsc.keywordTypeNode({ - keyword: 'boolean', - }), + type: tsc.keywordTypeNode({ keyword: 'boolean' }), }, { isRequired: false, name: 'tags', - type: tsc.typeReferenceNode({ - typeName: 'ReadonlyArray', - }), + type: tsc.typeReferenceNode({ typeName: 'ReadonlyArray' }), }, ]; + const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); + const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + sdkPlugin.api.getSelector('Options'), + ); + const symbolQueryKeyType = f + .ensureSymbol({ selector: plugin.api.getSelector('QueryKey') }) + .update({ name: 'QueryKey' }); const queryKeyType = tsc.typeAliasDeclaration({ exportType: true, - name: queryKeyName, + name: symbolQueryKeyType.placeholder, type: tsc.typeTupleNode({ types: [ tsc.typeIntersectionNode({ @@ -328,47 +344,29 @@ export const createQueryKeyType = ({ plugin }: { plugin: PluginInstance }) => { typeParameters: [ { extends: tsc.typeReferenceNode({ - typeName: tsc.identifier({ - text: clientApi.Options.name, - }), + typeName: tsc.identifier({ text: symbolOptions.placeholder }), }), name: TOptionsType, }, ], }); - file.add(queryKeyType); + symbolQueryKeyType.update({ value: queryKeyType }); }; export const queryKeyStatement = ({ isInfinite, operation, plugin, + symbol, typeQueryKey, }: { isInfinite: boolean; operation: IR.OperationObject; plugin: PluginInstance; + symbol: ICodegenSymbolOut; typeQueryKey?: string; }) => { - const file = plugin.context.file({ id: plugin.name })!; const typeData = useTypeData({ operation, plugin }); - const identifier = isInfinite - ? file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-infinite-query-key/${operation.id}`, - case: plugin.config.infiniteQueryKeys.case, - create: true, - nameTransformer: plugin.config.infiniteQueryKeys.name, - namespace: 'value', - }) - : file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-query-key/${operation.id}`, - case: plugin.config.queryKeys.case, - create: true, - nameTransformer: plugin.config.queryKeys.name, - namespace: 'value', - }); const statement = tsc.constVariable({ exportConst: true, expression: tsc.arrowFunction({ @@ -387,7 +385,7 @@ export const queryKeyStatement = ({ plugin, }), }), - name: identifier.name || '', + name: symbol.placeholder, }); return statement; }; diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryOptions.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryOptions.ts index 58301d7e8..c32b7dc76 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryOptions.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryOptions.ts @@ -1,6 +1,7 @@ import type ts from 'typescript'; import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createOperationComment, @@ -16,7 +17,6 @@ import { import type { PluginInstance, PluginState } from './types'; import { useTypeData } from './useType'; -const queryOptionsFn = 'queryOptions'; const optionsParamName = 'options'; export const createQueryOptions = ({ @@ -34,7 +34,7 @@ export const createQueryOptions = ({ return; } - const file = plugin.context.file({ id: plugin.name })!; + const f = plugin.gen.ensureFile(plugin.output); const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, @@ -48,32 +48,35 @@ export const createQueryOptions = ({ createQueryKeyFunction({ plugin }); state.hasCreateQueryKeyParamsFunction = true; } - - file.import({ - module: plugin.name, - name: queryOptionsFn, - }); } + const symbolQueryOptions = f.ensureSymbol({ + name: 'queryOptions', + selector: plugin.api.getSelector('queryOptions'), + }); + f.addImport({ + from: plugin.name, + names: [symbolQueryOptions.name], + }); + state.hasUsedQueryFn = true; + const symbolQueryKey = f.addSymbol({ + name: buildName({ + config: plugin.config.queryKeys, + name: operation.id, + }), + }); const node = queryKeyStatement({ isInfinite: false, operation, plugin, + symbol: symbolQueryKey, }); - file.add(node); + symbolQueryKey.update({ value: node }); const typeData = useTypeData({ operation, plugin }); - const identifierQueryKey = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-query-key/${operation.id}`, - case: plugin.config.queryKeys.case, - nameTransformer: plugin.config.queryKeys.name, - namespace: 'value', - }); - const awaitSdkExpression = tsc.awaitExpression({ expression: tsc.callExpression({ functionName: queryFn, @@ -106,7 +109,7 @@ export const createQueryOptions = ({ const statements: Array = []; - if (plugin.getPlugin('@hey-api/sdk')?.config.responseStyle === 'data') { + if (plugin.getPluginOrThrow('@hey-api/sdk').config.responseStyle === 'data') { statements.push( tsc.returnVariable({ expression: awaitSdkExpression, @@ -125,15 +128,6 @@ export const createQueryOptions = ({ ); } - const identifierQueryOptions = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-query-options/${operation.id}`, - case: plugin.config.queryOptions.case, - create: true, - nameTransformer: plugin.config.queryOptions.name, - namespace: 'value', - }); - const queryOptionsObj: Array<{ key: string; value: ts.Expression }> = [ { key: 'queryFn', @@ -158,7 +152,7 @@ export const createQueryOptions = ({ { key: 'queryKey', value: tsc.callExpression({ - functionName: identifierQueryKey.name || '', + functionName: symbolQueryKey.placeholder, parameters: [optionsParamName], }), }, @@ -173,6 +167,16 @@ export const createQueryOptions = ({ }); } + const symbolQueryOptionsFn = f + .ensureSymbol({ + selector: plugin.api.getSelector('queryOptionsFn', operation.id), + }) + .update({ + name: buildName({ + config: plugin.config.queryOptions, + name: operation.id, + }), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) @@ -189,13 +193,13 @@ export const createQueryOptions = ({ statements: [ tsc.returnFunctionCall({ args: [tsc.objectExpression({ obj: queryOptionsObj })], - name: queryOptionsFn, + name: symbolQueryOptions.placeholder, }), ], }), - name: identifierQueryOptions.name || '', + name: symbolQueryOptionsFn.placeholder, // TODO: add type error // TODO: AxiosError }); - file.add(statement); + symbolQueryOptionsFn.update({ value: statement }); }; diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/types.d.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/types.d.ts index f1d694b82..91fb26640 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/types.d.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/types.d.ts @@ -5,12 +5,13 @@ import type { TanStackSolidQueryPlugin } from '../solid-query/types'; import type { TanStackSvelteQueryPlugin } from '../svelte-query/types'; import type { TanStackVueQueryPlugin } from '../vue-query/types'; -export type PluginHandler = - | TanStackAngularQueryPlugin['Handler'] - | TanStackReactQueryPlugin['Handler'] - | TanStackSolidQueryPlugin['Handler'] - | TanStackSvelteQueryPlugin['Handler'] - | TanStackVueQueryPlugin['Handler']; +export interface PluginHandler { + (...args: Parameters): void; + (...args: Parameters): void; + (...args: Parameters): void; + (...args: Parameters): void; + (...args: Parameters): void; +} export type PluginInstance = | TanStackAngularQueryPlugin['Instance'] diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/useQuery.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/useQuery.ts index 764b64f5a..fb3af4449 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/useQuery.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/useQuery.ts @@ -1,4 +1,5 @@ import type { IR } from '../../../ir/types'; +import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createOperationComment, @@ -8,7 +9,6 @@ import { import type { PluginInstance, PluginState } from './types'; import { useTypeData } from './useType'; -const useQueryFn = 'useQuery'; const optionsParamName = 'options'; export const createUseQuery = ({ @@ -24,33 +24,30 @@ export const createUseQuery = ({ return; } - const file = plugin.context.file({ id: plugin.name })!; + if (!('useQuery' in plugin.config)) { + return; + } + + const f = plugin.gen.ensureFile(plugin.output); + + const symbolUseQueryFn = f.addSymbol({ + name: buildName({ + config: plugin.config.useQuery, + name: operation.id, + }), + }); if (!state.hasUseQuery) { state.hasUseQuery = true; - - file.import({ - module: plugin.name, - name: useQueryFn, - }); } - const identifierUseQuery = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-use-query/${operation.id}`, - case: 'useQuery' in plugin.config ? plugin.config.useQuery.case : undefined, - create: true, - nameTransformer: - 'useQuery' in plugin.config ? plugin.config.useQuery.name : undefined, - namespace: 'value', + const symbolUseQuery = f.ensureSymbol({ + name: 'useQuery', + selector: plugin.api.getSelector('useQuery'), }); - - const identifierQueryOptions = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/tanstack-query-query-options/${operation.id}`, - case: plugin.config.queryOptions.case, - nameTransformer: plugin.config.queryOptions.name, - namespace: 'value', + f.addImport({ + from: plugin.name, + names: [symbolUseQuery.name], }); const isRequiredOptions = isOperationOptionsRequired({ @@ -59,6 +56,9 @@ export const createUseQuery = ({ }); const typeData = useTypeData({ operation, plugin }); + const symbolQueryOptionsFn = f.ensureSymbol({ + selector: plugin.api.getSelector('queryOptionsFn', operation.id), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) @@ -75,10 +75,10 @@ export const createUseQuery = ({ statements: [ tsc.returnStatement({ expression: tsc.callExpression({ - functionName: useQueryFn, + functionName: symbolUseQuery.placeholder, parameters: [ tsc.callExpression({ - functionName: identifierQueryOptions.name || '', + functionName: symbolQueryOptionsFn.placeholder, parameters: [optionsParamName], }), ], @@ -86,7 +86,7 @@ export const createUseQuery = ({ }), ], }), - name: identifierUseQuery.name || '', + name: symbolUseQueryFn.placeholder, }); - file.add(statement); + symbolUseQueryFn.update({ value: statement }); }; diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/useType.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/useType.ts index 0352a5bf2..12bb95829 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/useType.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/useType.ts @@ -1,8 +1,6 @@ import type { IR } from '../../../ir/types'; -import type { ImportExportItemObject } from '../../../tsc/utils'; import { getClientPlugin } from '../../@hey-api/client-core/utils'; import { operationOptionsType } from '../../@hey-api/sdk/operation'; -import { typesId } from '../../@hey-api/typescript/ref'; import type { PluginInstance } from './types'; export const useTypeData = ({ @@ -11,10 +9,14 @@ export const useTypeData = ({ }: { operation: IR.OperationObject; plugin: PluginInstance; -}) => { - const file = plugin.context.file({ id: plugin.name })!; - const pluginSdk = plugin.getPlugin('@hey-api/sdk')!; - const typeData = operationOptionsType({ file, operation, plugin: pluginSdk }); +}): string => { + const f = plugin.gen.ensureFile(plugin.output); + const pluginSdk = plugin.getPluginOrThrow('@hey-api/sdk'); + const typeData = operationOptionsType({ + file: f, + operation, + plugin: pluginSdk, + }); return typeData; }; @@ -24,41 +26,43 @@ export const useTypeError = ({ }: { operation: IR.OperationObject; plugin: PluginInstance; -}) => { - const file = plugin.context.file({ id: plugin.name })!; - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const errorImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'error' }), - ), - }); - let typeError: ImportExportItemObject = { - asType: true, - name: errorImport.name || '', - }; - if (!typeError.name) { - typeError = file.import({ - asType: true, - module: plugin.name, - name: 'DefaultError', +}): string => { + const f = plugin.gen.ensureFile(plugin.output); + const client = getClientPlugin(plugin.context.config); + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + + const symbolErrorType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('error', operation.id), + ); + if (symbolErrorType) { + f.addImport({ + from: symbolErrorType.file, + typeNames: [symbolErrorType.placeholder], }); } - const client = getClientPlugin(plugin.context.config); + + let typeErrorName: string | undefined = symbolErrorType?.placeholder; + if (!typeErrorName) { + const symbol = f + .ensureSymbol({ selector: plugin.api.getSelector('DefaultError') }) + .update({ name: 'DefaultError' }); + f.addImport({ + from: plugin.name, + typeNames: [symbol.placeholder], + }); + typeErrorName = symbol.placeholder; + } if (client.name === '@hey-api/client-axios') { - const axiosError = file.import({ - asType: true, - module: 'axios', - name: 'AxiosError', + const symbol = f + .ensureSymbol({ selector: plugin.api.getSelector('AxiosError') }) + .update({ name: 'AxiosError' }); + f.addImport({ + from: 'axios', + typeNames: [symbol.placeholder], }); - typeError = { - ...axiosError, - name: `${axiosError.name}<${typeError.name}>`, - }; + typeErrorName = `${symbol.placeholder}<${typeErrorName}>`; } - return typeError; + return typeErrorName; }; export const useTypeResponse = ({ @@ -67,18 +71,17 @@ export const useTypeResponse = ({ }: { operation: IR.OperationObject; plugin: PluginInstance; -}) => { - const file = plugin.context.file({ id: plugin.name })!; - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const responseImport = file.import({ - asType: true, - module: file.relativePathToFile({ context: plugin.context, id: typesId }), - name: fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'response' }), - ), - }); - - const typeResponse = responseImport.name || 'unknown'; - return typeResponse; +}): string => { + const f = plugin.gen.ensureFile(plugin.output); + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + const symbolResponseType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('response', operation.id), + ); + if (symbolResponseType) { + f.addImport({ + from: symbolResponseType.file, + typeNames: [symbolResponseType.placeholder], + }); + } + return symbolResponseType?.placeholder || 'unknown'; }; diff --git a/packages/openapi-ts/src/plugins/@tanstack/react-query/api.ts b/packages/openapi-ts/src/plugins/@tanstack/react-query/api.ts new file mode 100644 index 000000000..deb578eaa --- /dev/null +++ b/packages/openapi-ts/src/plugins/@tanstack/react-query/api.ts @@ -0,0 +1,46 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | 'AxiosError' + | 'createInfiniteParams' + | 'createQueryKey' + | 'DefaultError' + | 'infiniteQueryOptions' + | 'InfiniteData' + | 'MutationOptions' + | 'queryOptions' + | 'queryOptionsFn' + | 'QueryKey' + | 'useQuery'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `AxiosError`: never + * - `createInfiniteParams`: never + * - `createQueryKey`: never + * - `DefaultError`: never + * - `infiniteQueryOptions`: never + * - `InfiniteData`: never + * - `MutationOptions`: never + * - `queryOptions`: never + * - `queryOptionsFn`: `operation.id` string + * - `QueryKey`: never + * - `useQuery`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@tanstack/react-query'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts b/packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts index ec0a15052..6e6f1b1bf 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/react-query/config.ts @@ -1,9 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; import { handler } from '../query-core/plugin'; import { handlerLegacy } from '../query-core/plugin-legacy'; +import { Api } from './api'; import type { TanStackReactQueryPlugin } from './types'; export const defaultConfig: TanStackReactQueryPlugin['Config'] = { + api: new Api({ + name: '@tanstack/react-query', + }), config: { case: 'camelCase', comments: true, diff --git a/packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts b/packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts index ec271bde6..85c5493d4 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/react-query/types.d.ts @@ -1,6 +1,7 @@ import type { IR } from '../../../ir/types'; import type { StringCase, StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@tanstack/react-query'> & Plugin.Hooks & { @@ -633,4 +634,4 @@ export type Config = Plugin.Name<'@tanstack/react-query'> & }; }; -export type TanStackReactQueryPlugin = DefinePlugin; +export type TanStackReactQueryPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts b/packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts new file mode 100644 index 000000000..4a7a1c027 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts @@ -0,0 +1,46 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | 'AxiosError' + | 'createInfiniteParams' + | 'createQueryKey' + | 'DefaultError' + | 'infiniteQueryOptions' + | 'InfiniteData' + | 'MutationOptions' + | 'queryOptions' + | 'queryOptionsFn' + | 'QueryKey' + | 'useQuery'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `AxiosError`: never + * - `createInfiniteParams`: never + * - `createQueryKey`: never + * - `DefaultError`: never + * - `infiniteQueryOptions`: never + * - `InfiniteData`: never + * - `MutationOptions`: never + * - `queryOptions`: never + * - `queryOptionsFn`: `operation.id` string + * - `QueryKey`: never + * - `useQuery`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@tanstack/solid-query'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts b/packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts index 7dec821d7..a1e6915c3 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/solid-query/config.ts @@ -1,9 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; import { handler } from '../query-core/plugin'; import { handlerLegacy } from '../query-core/plugin-legacy'; +import { Api } from './api'; import type { TanStackSolidQueryPlugin } from './types'; export const defaultConfig: TanStackSolidQueryPlugin['Config'] = { + api: new Api({ + name: '@tanstack/solid-query', + }), config: { case: 'camelCase', comments: true, diff --git a/packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts b/packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts index 9cb01739e..9ac1e9467 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/solid-query/types.d.ts @@ -1,6 +1,7 @@ import type { IR } from '../../../ir/types'; import type { StringCase, StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@tanstack/solid-query'> & Plugin.Hooks & { @@ -556,4 +557,4 @@ export type Config = Plugin.Name<'@tanstack/solid-query'> & }; }; -export type TanStackSolidQueryPlugin = DefinePlugin; +export type TanStackSolidQueryPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts new file mode 100644 index 000000000..7cd44eb33 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts @@ -0,0 +1,46 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | 'AxiosError' + | 'createInfiniteParams' + | 'createQueryKey' + | 'DefaultError' + | 'infiniteQueryOptions' + | 'InfiniteData' + | 'MutationOptions' + | 'queryOptions' + | 'queryOptionsFn' + | 'QueryKey' + | 'useQuery'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `AxiosError`: never + * - `createInfiniteParams`: never + * - `createQueryKey`: never + * - `DefaultError`: never + * - `infiniteQueryOptions`: never + * - `InfiniteData`: never + * - `MutationOptions`: never + * - `queryOptions`: never + * - `queryOptionsFn`: `operation.id` string + * - `QueryKey`: never + * - `useQuery`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@tanstack/svelte-query'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts index e9860011d..f4c400bae 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/config.ts @@ -1,9 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; import { handler } from '../query-core/plugin'; import { handlerLegacy } from '../query-core/plugin-legacy'; +import { Api } from './api'; import type { TanStackSvelteQueryPlugin } from './types'; export const defaultConfig: TanStackSvelteQueryPlugin['Config'] = { + api: new Api({ + name: '@tanstack/svelte-query', + }), config: { case: 'camelCase', comments: true, diff --git a/packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts index 1f930e349..9a343483c 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/types.d.ts @@ -1,6 +1,7 @@ import type { IR } from '../../../ir/types'; import type { StringCase, StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@tanstack/svelte-query'> & Plugin.Hooks & { @@ -555,4 +556,4 @@ export type Config = Plugin.Name<'@tanstack/svelte-query'> & }; }; -export type TanStackSvelteQueryPlugin = DefinePlugin; +export type TanStackSvelteQueryPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts b/packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts new file mode 100644 index 000000000..ea1bf2080 --- /dev/null +++ b/packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts @@ -0,0 +1,46 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../../types'; + +type SelectorType = + | 'AxiosError' + | 'createInfiniteParams' + | 'createQueryKey' + | 'DefaultError' + | 'infiniteQueryOptions' + | 'InfiniteData' + | 'MutationOptions' + | 'queryOptions' + | 'queryOptionsFn' + | 'QueryKey' + | 'useQuery'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `AxiosError`: never + * - `createInfiniteParams`: never + * - `createQueryKey`: never + * - `DefaultError`: never + * - `infiniteQueryOptions`: never + * - `InfiniteData`: never + * - `MutationOptions`: never + * - `queryOptions`: never + * - `queryOptionsFn`: `operation.id` string + * - `QueryKey`: never + * - `useQuery`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'@tanstack/vue-query'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts b/packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts index 80c24ff89..c07182142 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/vue-query/config.ts @@ -1,9 +1,13 @@ import { definePluginConfig } from '../../shared/utils/config'; import { handler } from '../query-core/plugin'; import { handlerLegacy } from '../query-core/plugin-legacy'; +import { Api } from './api'; import type { TanStackVueQueryPlugin } from './types'; export const defaultConfig: TanStackVueQueryPlugin['Config'] = { + api: new Api({ + name: '@tanstack/vue-query', + }), config: { case: 'camelCase', comments: true, diff --git a/packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts b/packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts index 39f72a528..accee34a2 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/vue-query/types.d.ts @@ -1,6 +1,7 @@ import type { IR } from '../../../ir/types'; import type { StringCase, StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'@tanstack/vue-query'> & Plugin.Hooks & { @@ -561,4 +562,4 @@ export type Config = Plugin.Name<'@tanstack/vue-query'> & }; }; -export type TanStackVueQueryPlugin = DefinePlugin; +export type TanStackVueQueryPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/fastify/api.ts b/packages/openapi-ts/src/plugins/fastify/api.ts new file mode 100644 index 000000000..8ec88344e --- /dev/null +++ b/packages/openapi-ts/src/plugins/fastify/api.ts @@ -0,0 +1,25 @@ +import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; + +import type { Plugin } from '../types'; + +type SelectorType = 'RouteHandler'; + +export type IApi = { + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `RouteHandler`: never + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'fastify'>) {} + + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/fastify/config.ts b/packages/openapi-ts/src/plugins/fastify/config.ts index 9f2c1d351..31a440609 100644 --- a/packages/openapi-ts/src/plugins/fastify/config.ts +++ b/packages/openapi-ts/src/plugins/fastify/config.ts @@ -1,8 +1,12 @@ import { definePluginConfig } from '../shared/utils/config'; +import { Api } from './api'; import { handler } from './plugin'; import type { FastifyPlugin } from './types'; export const defaultConfig: FastifyPlugin['Config'] = { + api: new Api({ + name: 'fastify', + }), config: { exportFromIndex: false, }, diff --git a/packages/openapi-ts/src/plugins/fastify/plugin.ts b/packages/openapi-ts/src/plugins/fastify/plugin.ts index fdcce8e8c..efa0ccaad 100644 --- a/packages/openapi-ts/src/plugins/fastify/plugin.ts +++ b/packages/openapi-ts/src/plugins/fastify/plugin.ts @@ -1,14 +1,12 @@ import type ts from 'typescript'; +import { TypeScriptRenderer } from '../../generate/renderer'; import { operationResponsesMap } from '../../ir/operation'; import { hasParameterGroupObjectRequired } from '../../ir/parameter'; import type { IR } from '../../ir/types'; import { type Property, tsc } from '../../tsc'; -import { typesId } from '../@hey-api/typescript/ref'; import type { FastifyPlugin } from './types'; -const fastifyId = 'fastify'; - const operationToRouteHandler = ({ operation, plugin, @@ -16,84 +14,67 @@ const operationToRouteHandler = ({ operation: IR.OperationObject; plugin: FastifyPlugin['Instance']; }): Property | undefined => { - const file = plugin.context.file({ id: fastifyId })!; + const f = plugin.gen.ensureFile(plugin.output); const properties: Array = []; - const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; - const fileTypeScript = plugin.context.file({ id: typesId })!; - const dataName = fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'data' }), + const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); + const symbolDataType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('data', operation.id), ); - if (dataName) { + if (symbolDataType) { if (operation.body) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: dataName, + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], }); properties.push({ isRequired: operation.body.required, name: 'Body', - type: `${dataName}['body']`, + type: `${symbolDataType.placeholder}['body']`, }); } if (operation.parameters) { if (operation.parameters.header) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: dataName, + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], }); properties.push({ isRequired: hasParameterGroupObjectRequired( operation.parameters.header, ), name: 'Headers', - type: `${dataName}['headers']`, + type: `${symbolDataType.placeholder}['headers']`, }); } if (operation.parameters.path) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: dataName, + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], }); properties.push({ isRequired: hasParameterGroupObjectRequired( operation.parameters.path, ), name: 'Params', - type: `${dataName}['path']`, + type: `${symbolDataType.placeholder}['path']`, }); } if (operation.parameters.query) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: dataName, + f.addImport({ + from: symbolDataType.file, + typeNames: [symbolDataType.placeholder], }); properties.push({ isRequired: hasParameterGroupObjectRequired( operation.parameters.query, ), name: 'Querystring', - type: `${dataName}['query']`, + type: `${symbolDataType.placeholder}['query']`, }); } } @@ -102,36 +83,28 @@ const operationToRouteHandler = ({ const { errors, responses } = operationResponsesMap(operation); let errorsTypeReference: ts.TypeReferenceNode | undefined = undefined; - const errorName = fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'errors' }), + const symbolErrorType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('errors', operation.id), ); - if (errorName && errors && errors.properties) { + if (symbolErrorType && errors && errors.properties) { const keys = Object.keys(errors.properties); if (keys.length) { const hasDefaultResponse = keys.includes('default'); if (!hasDefaultResponse) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: errorName, + f.addImport({ + from: symbolErrorType.file, + typeNames: [symbolErrorType.placeholder], }); errorsTypeReference = tsc.typeReferenceNode({ - typeName: errorName, + typeName: symbolErrorType.placeholder, }); } else if (keys.length > 1) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: errorName, + f.addImport({ + from: symbolErrorType.file, + typeNames: [symbolErrorType.placeholder], }); const errorsType = tsc.typeReferenceNode({ - typeName: errorName, + typeName: symbolErrorType.placeholder, }); const defaultType = tsc.literalTypeNode({ literal: tsc.stringLiteral({ text: 'default' }), @@ -145,36 +118,28 @@ const operationToRouteHandler = ({ } let responsesTypeReference: ts.TypeReferenceNode | undefined = undefined; - const responseName = fileTypeScript.getName( - pluginTypeScript.api.getId({ operation, type: 'responses' }), + const symbolResponseType = plugin.gen.selectSymbolFirst( + pluginTypeScript.api.getSelector('responses', operation.id), ); - if (responseName && responses && responses.properties) { + if (symbolResponseType && responses && responses.properties) { const keys = Object.keys(responses.properties); if (keys.length) { const hasDefaultResponse = keys.includes('default'); if (!hasDefaultResponse) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: responseName, + f.addImport({ + from: symbolResponseType.file, + typeNames: [symbolResponseType.placeholder], }); responsesTypeReference = tsc.typeReferenceNode({ - typeName: responseName, + typeName: symbolResponseType.placeholder, }); } else if (keys.length > 1) { - file.import({ - asType: true, - module: file.relativePathToFile({ - context: plugin.context, - id: typesId, - }), - name: responseName, + f.addImport({ + from: symbolResponseType.file, + typeNames: [symbolResponseType.placeholder], }); const responsesType = tsc.typeReferenceNode({ - typeName: responseName, + typeName: symbolResponseType.placeholder, }); const defaultType = tsc.literalTypeNode({ literal: tsc.stringLiteral({ text: 'default' }), @@ -203,22 +168,29 @@ const operationToRouteHandler = ({ return; } + const symbolRouteHandler = f.ensureSymbol({ + selector: plugin.api.getSelector('RouteHandler'), + }); const routeHandler: Property = { name: operation.id, - type: tsc.typeNode('RouteHandler', [ - tsc.typeInterfaceNode({ - properties, - useLegacyResolution: false, - }), - ]), + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.typeInterfaceNode({ + properties, + useLegacyResolution: false, + }), + ], + typeName: symbolRouteHandler.placeholder, + }), }; return routeHandler; }; export const handler: FastifyPlugin['Handler'] = ({ plugin }) => { - const file = plugin.createFile({ - id: fastifyId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); const routeHandlers: Array = []; @@ -230,32 +202,25 @@ export const handler: FastifyPlugin['Handler'] = ({ plugin }) => { } }); - const identifier = file.identifier({ - $ref: 'RouteHandlers', - create: true, - namespace: 'type', - }); - - if (!identifier.name) { - return; - } + const symbolRouteHandlers = f.addSymbol({ name: 'RouteHandlers' }); if (routeHandlers.length) { - file.import({ - asType: true, - module: 'fastify', - name: 'RouteHandler', + const symbolRouteHandler = f + .ensureSymbol({ selector: plugin.api.getSelector('RouteHandler') }) + .update({ name: 'RouteHandler' }); + f.addImport({ + from: 'fastify', + typeNames: [symbolRouteHandler.name], }); } - file.add( - tsc.typeAliasDeclaration({ - exportType: true, - name: identifier.name, - type: tsc.typeInterfaceNode({ - properties: routeHandlers, - useLegacyResolution: false, - }), + const node = tsc.typeAliasDeclaration({ + exportType: true, + name: symbolRouteHandlers.placeholder, + type: tsc.typeInterfaceNode({ + properties: routeHandlers, + useLegacyResolution: false, }), - ); + }); + symbolRouteHandlers.update({ value: node }); }; diff --git a/packages/openapi-ts/src/plugins/fastify/types.d.ts b/packages/openapi-ts/src/plugins/fastify/types.d.ts index b3cb648a7..ec050bcda 100644 --- a/packages/openapi-ts/src/plugins/fastify/types.d.ts +++ b/packages/openapi-ts/src/plugins/fastify/types.d.ts @@ -1,4 +1,5 @@ import type { DefinePlugin, Plugin } from '../types'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'fastify'> & { /** @@ -16,4 +17,4 @@ export type UserConfig = Plugin.Name<'fastify'> & { output?: string; }; -export type FastifyPlugin = DefinePlugin; +export type FastifyPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/shared/utils/instance.ts b/packages/openapi-ts/src/plugins/shared/utils/instance.ts index 9da732155..d4981a17b 100644 --- a/packages/openapi-ts/src/plugins/shared/utils/instance.ts +++ b/packages/openapi-ts/src/plugins/shared/utils/instance.ts @@ -243,6 +243,22 @@ export class PluginInstance { return this.context.plugins[name] as any; } + /** + * Retrieves a registered plugin instance by its name from the context. This + * allows plugins to access other plugins that have been registered in the + * same context, enabling cross-plugin communication and dependencies. + * + * @param name Plugin name as defined in the configuration. + * @returns The plugin instance if found, throw otherwise. + */ + getPluginOrThrow( + name: T, + ): T extends any ? PluginInstance : never { + const plugin = this.getPlugin(name); + if (!plugin) throw new Error(`plugin not found ${name}`); + return plugin as any; + } + hooks = { operation: { isMutation: (operation: IR.OperationObject): boolean => diff --git a/packages/openapi-ts/src/plugins/valibot/api.ts b/packages/openapi-ts/src/plugins/valibot/api.ts index 4b7a4132b..78b24d390 100644 --- a/packages/openapi-ts/src/plugins/valibot/api.ts +++ b/packages/openapi-ts/src/plugins/valibot/api.ts @@ -1,165 +1,145 @@ +import type { + ICodegenFile, + ICodegenSymbolSelector, +} from '@hey-api/codegen-core'; import type ts from 'typescript'; -import type { GeneratedFile } from '../../generate/file'; import type { IR } from '../../ir/types'; import { tsc } from '../../tsc'; -import { identifiers, valibotId } from './constants'; +import type { Plugin } from '../types'; +import { identifiers } from './constants'; import type { ValibotPlugin } from './types'; -const createRequestValidator = ({ - file, - operation, - plugin, -}: { - file: GeneratedFile; +type SelectorType = 'data' | 'import' | 'ref' | 'responses' | 'webhook-request'; + +type ValidatorArgs = { + file: ICodegenFile; operation: IR.OperationObject; plugin: ValibotPlugin['Instance']; -}): ts.ArrowFunction | undefined => { - const { requests } = plugin.config; - // const f = plugin.gen.ensureFile(plugin.output); - // TODO: replace - const schemaIdentifier = plugin.context.file({ id: valibotId })!.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/valibot-response/${operation.id}`, - // TODO: refactor to not have to define nameTransformer - nameTransformer: typeof requests === 'object' ? requests.name : undefined, - namespace: 'value', - }); - - if (!schemaIdentifier.name) { - return; - } +}; + +export type IApi = { + createRequestValidator: (args: ValidatorArgs) => ts.ArrowFunction | undefined; + createResponseValidator: ( + args: ValidatorArgs, + ) => ts.ArrowFunction | undefined; + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `data`: `operation.id` string + * - `import`: headless symbols representing module imports + * - `ref`: `$ref` JSON pointer + * - `responses`: `operation.id` string + * - `webhook-request`: `operation.id` string + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'valibot'>) {} - file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: valibotId, - }), - name: schemaIdentifier.name, - }); - // file.import({ - // module: f.relativePathFromFile({ path: file.nameWithoutExtension() }), - // name: schemaIdentifier.name, - // }); - - file.import({ - alias: identifiers.v.text, - module: 'valibot', - name: '*', - }); - - const dataParameterName = 'data'; - - return tsc.arrowFunction({ - async: true, - parameters: [ - { - name: dataParameterName, - }, - ], - statements: [ - tsc.returnStatement({ - expression: tsc.awaitExpression({ - expression: tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, - name: identifiers.async.parseAsync, + createRequestValidator({ + file, + operation, + plugin, + }: ValidatorArgs): ts.ArrowFunction | undefined { + const symbol = plugin.gen.selectSymbolFirst( + plugin.api.getSelector('data', operation.id), + ); + if (!symbol) return; + + file.addImport({ + from: symbol.file, + names: [symbol.placeholder], + }); + + const vSymbol = file.ensureSymbol({ + name: 'v', + selector: plugin.api.getSelector('import', 'valibot'), + }); + file.addImport({ from: 'valibot', namespaceImport: vSymbol.placeholder }); + + const dataParameterName = 'data'; + + return tsc.arrowFunction({ + async: true, + parameters: [ + { + name: dataParameterName, + }, + ], + statements: [ + tsc.returnStatement({ + expression: tsc.awaitExpression({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: vSymbol.placeholder, + name: identifiers.async.parseAsync, + }), + parameters: [ + tsc.identifier({ text: symbol.placeholder }), + tsc.identifier({ text: dataParameterName }), + ], }), - parameters: [ - tsc.identifier({ text: schemaIdentifier.name }), - tsc.identifier({ text: dataParameterName }), - ], }), }), - }), - ], - }); -}; - -const createResponseValidator = ({ - file, - operation, - plugin, -}: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: ValibotPlugin['Instance']; -}): ts.ArrowFunction | undefined => { - const { responses } = plugin.config; - // const f = plugin.gen.ensureFile(plugin.output); - // TODO: replace - const schemaIdentifier = plugin.context.file({ id: valibotId })!.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/valibot-response/${operation.id}`, - // TODO: refactor to not have to define nameTransformer - nameTransformer: typeof responses === 'object' ? responses.name : undefined, - namespace: 'value', - }); - - if (!schemaIdentifier.name) { - return; + ], + }); } - file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: valibotId, - }), - name: schemaIdentifier.name, - }); - // file.import({ - // module: f.relativePathFromFile({ path: file.nameWithoutExtension() }), - // name: schemaIdentifier.name, - // }); - - file.import({ - alias: identifiers.v.text, - module: 'valibot', - name: '*', - }); - - const dataParameterName = 'data'; - - return tsc.arrowFunction({ - async: true, - parameters: [ - { - name: dataParameterName, - }, - ], - statements: [ - tsc.returnStatement({ - expression: tsc.awaitExpression({ - expression: tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, - name: identifiers.async.parseAsync, + createResponseValidator({ + file, + operation, + plugin, + }: ValidatorArgs): ts.ArrowFunction | undefined { + const symbol = plugin.gen.selectSymbolFirst( + plugin.api.getSelector('responses', operation.id), + ); + if (!symbol) return; + + file.addImport({ + from: symbol.file, + names: [symbol.placeholder], + }); + + const vSymbol = file.ensureSymbol({ + name: 'v', + selector: plugin.api.getSelector('import', 'valibot'), + }); + file.addImport({ from: 'valibot', namespaceImport: vSymbol.placeholder }); + + const dataParameterName = 'data'; + + return tsc.arrowFunction({ + async: true, + parameters: [ + { + name: dataParameterName, + }, + ], + statements: [ + tsc.returnStatement({ + expression: tsc.awaitExpression({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: vSymbol.placeholder, + name: identifiers.async.parseAsync, + }), + parameters: [ + tsc.identifier({ text: symbol.placeholder }), + tsc.identifier({ text: dataParameterName }), + ], }), - parameters: [ - tsc.identifier({ text: schemaIdentifier.name }), - tsc.identifier({ text: dataParameterName }), - ], }), }), - }), - ], - }); -}; - -export type Api = { - createRequestValidator: (args: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: ValibotPlugin['Instance']; - }) => ts.ArrowFunction | undefined; - createResponseValidator: (args: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: ValibotPlugin['Instance']; - }) => ts.ArrowFunction | undefined; -}; + ], + }); + } -export const api: Api = { - createRequestValidator, - createResponseValidator, -}; + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/valibot/config.ts b/packages/openapi-ts/src/plugins/valibot/config.ts index 408a7ef85..6b45870d1 100644 --- a/packages/openapi-ts/src/plugins/valibot/config.ts +++ b/packages/openapi-ts/src/plugins/valibot/config.ts @@ -1,10 +1,12 @@ import { definePluginConfig } from '../shared/utils/config'; -import { api } from './api'; +import { Api } from './api'; import { handler } from './plugin'; import type { ValibotPlugin } from './types'; export const defaultConfig: ValibotPlugin['Config'] = { - api, + api: new Api({ + name: 'valibot', + }), config: { case: 'camelCase', comments: true, diff --git a/packages/openapi-ts/src/plugins/valibot/constants.ts b/packages/openapi-ts/src/plugins/valibot/constants.ts index 69b6a6c7b..5f1790715 100644 --- a/packages/openapi-ts/src/plugins/valibot/constants.ts +++ b/packages/openapi-ts/src/plugins/valibot/constants.ts @@ -263,7 +263,4 @@ export const identifiers = { utils: { // TODO: implement if necessary }, - v: tsc.identifier({ text: 'v' }), }; - -export const valibotId = 'valibot'; diff --git a/packages/openapi-ts/src/plugins/valibot/operation.ts b/packages/openapi-ts/src/plugins/valibot/operation.ts index d4c249bbc..033ec060e 100644 --- a/packages/openapi-ts/src/plugins/valibot/operation.ts +++ b/packages/openapi-ts/src/plugins/valibot/operation.ts @@ -1,6 +1,6 @@ import { operationResponsesMap } from '../../ir/operation'; import type { IR } from '../../ir/types'; -import { valibotId } from './constants'; +import { buildName } from '../../openApi/shared/utils/name'; import { schemaToValibotSchema, type State } from './plugin'; import type { ValibotPlugin } from './types'; @@ -13,8 +13,6 @@ export const operationToValibotSchema = ({ plugin: ValibotPlugin['Instance']; state: State; }) => { - const file = plugin.context.file({ id: valibotId })!; - if (plugin.config.requests.enabled) { const requiredProperties = new Set(); @@ -113,21 +111,21 @@ export const operationToValibotSchema = ({ schemaData.required = [...requiredProperties]; - const identifierData = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/valibot-data/${operation.id}`, - case: plugin.config.requests.case, - create: true, - nameTransformer: plugin.config.requests.name, - namespace: 'value', + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f.addSymbol({ + name: buildName({ + config: plugin.config.requests, + name: operation.id, + }), + selector: plugin.api.getSelector('data', operation.id), }); schemaToValibotSchema({ // TODO: refactor for better cross-plugin compatibility $ref: `#/valibot-data/${operation.id}`, - identifier: identifierData, plugin, schema: schemaData, state, + symbol, }); } @@ -136,21 +134,21 @@ export const operationToValibotSchema = ({ const { response } = operationResponsesMap(operation); if (response) { - const identifierResponse = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/valibot-response/${operation.id}`, - case: plugin.config.responses.case, - create: true, - nameTransformer: plugin.config.responses.name, - namespace: 'value', + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f.addSymbol({ + name: buildName({ + config: plugin.config.responses, + name: operation.id, + }), + selector: plugin.api.getSelector('responses', operation.id), }); schemaToValibotSchema({ // TODO: refactor for better cross-plugin compatibility $ref: `#/valibot-response/${operation.id}`, - identifier: identifierResponse, plugin, schema: response, state, + symbol, }); } } diff --git a/packages/openapi-ts/src/plugins/valibot/plugin.ts b/packages/openapi-ts/src/plugins/valibot/plugin.ts index 0b1c1d48d..f45ac4496 100644 --- a/packages/openapi-ts/src/plugins/valibot/plugin.ts +++ b/packages/openapi-ts/src/plugins/valibot/plugin.ts @@ -1,14 +1,16 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import ts from 'typescript'; -import type { Identifier } from '../../generate/file/types'; -// import { TypeScriptRenderer } from '../../generate/renderer'; +import { TypeScriptRenderer } from '../../generate/renderer'; import { deduplicateSchema } from '../../ir/schema'; import type { IR } from '../../ir/types'; +import { buildName } from '../../openApi/shared/utils/name'; import { tsc } from '../../tsc'; import type { StringCase, StringName } from '../../types/case'; +import { refToName } from '../../utils/ref'; import { numberRegExp } from '../../utils/regexp'; import { createSchemaComment } from '../shared/utils/schema'; -import { identifiers, valibotId } from './constants'; +import { identifiers } from './constants'; import { INTEGER_FORMATS, isIntegerFormat, @@ -31,14 +33,23 @@ export interface State { nameTransformer: StringName; } -const pipesToExpression = (pipes: Array) => { +const pipesToExpression = ({ + pipes, + plugin, +}: { + pipes: Array; + plugin: ValibotPlugin['Instance']; +}) => { if (pipes.length === 1) { return pipes[0]!; } + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.methods.pipe, }), parameters: pipes, @@ -55,8 +66,11 @@ const arrayTypeToValibotSchema = ({ schema: SchemaWithType<'array'>; state: State; }): ts.Expression => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); const functionName = tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.array, }); @@ -67,6 +81,7 @@ const arrayTypeToValibotSchema = ({ functionName, parameters: [ unknownTypeToValibotSchema({ + plugin, schema: { type: 'unknown', }, @@ -84,7 +99,7 @@ const arrayTypeToValibotSchema = ({ schema: item, state, }); - return pipesToExpression(schemaPipes); + return pipesToExpression({ pipes: schemaPipes, plugin }); }); if (itemExpressions.length === 1) { @@ -108,6 +123,7 @@ const arrayTypeToValibotSchema = ({ functionName, parameters: [ unknownTypeToValibotSchema({ + plugin, schema: { type: 'unknown', }, @@ -121,7 +137,7 @@ const arrayTypeToValibotSchema = ({ if (schema.minItems === schema.maxItems && schema.minItems !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.length, }), parameters: [tsc.valueToExpression({ value: schema.minItems })], @@ -131,7 +147,7 @@ const arrayTypeToValibotSchema = ({ if (schema.minItems !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.minLength, }), parameters: [tsc.valueToExpression({ value: schema.minItems })], @@ -142,7 +158,7 @@ const arrayTypeToValibotSchema = ({ if (schema.maxItems !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.maxLength, }), parameters: [tsc.valueToExpression({ value: schema.maxItems })], @@ -151,18 +167,24 @@ const arrayTypeToValibotSchema = ({ } } - return pipesToExpression(pipes); + return pipesToExpression({ pipes, plugin }); }; const booleanTypeToValibotSchema = ({ + plugin, schema, }: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'boolean'>; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + if (typeof schema.const === 'boolean') { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.literal, }), parameters: [tsc.ots.boolean(schema.const)], @@ -172,7 +194,7 @@ const booleanTypeToValibotSchema = ({ const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.boolean, }), }); @@ -180,8 +202,10 @@ const booleanTypeToValibotSchema = ({ }; const enumTypeToValibotSchema = ({ + plugin, schema, }: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'enum'>; }): ts.CallExpression => { const enumMembers: Array = []; @@ -203,15 +227,20 @@ const enumTypeToValibotSchema = ({ if (!enumMembers.length) { return unknownTypeToValibotSchema({ + plugin, schema: { type: 'unknown', }, }); } + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + let resultExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.picklist, }), parameters: [ @@ -225,7 +254,7 @@ const enumTypeToValibotSchema = ({ if (isNullable) { resultExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.nullable, }), parameters: [resultExpression], @@ -235,26 +264,36 @@ const enumTypeToValibotSchema = ({ return resultExpression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const neverTypeToValibotSchema = (_props: { +const neverTypeToValibotSchema = ({ + plugin, +}: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'never'>; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.never, }), }); return expression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const nullTypeToValibotSchema = (_props: { +const nullTypeToValibotSchema = ({ + plugin, +}: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'null'>; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.null, }), }); @@ -262,8 +301,10 @@ const nullTypeToValibotSchema = (_props: { }; const numberTypeToValibotSchema = ({ + plugin, schema, }: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'integer' | 'number'>; }) => { const format = schema.format; @@ -271,6 +312,10 @@ const numberTypeToValibotSchema = ({ const isBigInt = needsBigIntForFormat(format); const formatInfo = isIntegerFormat(format) ? INTEGER_FORMATS[format] : null; + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + // Return early if const is defined since we can create a literal type directly without additional validation if (schema.const !== undefined && schema.const !== null) { const constValue = schema.const; @@ -323,7 +368,7 @@ const numberTypeToValibotSchema = ({ return tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.literal, }), parameters: [literalValue], @@ -336,7 +381,7 @@ const numberTypeToValibotSchema = ({ if (isBigInt) { const unionExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.union, }), parameters: [ @@ -344,19 +389,19 @@ const numberTypeToValibotSchema = ({ elements: [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.number, }), }), tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.string, }), }), tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.bigInt, }), }), @@ -370,7 +415,7 @@ const numberTypeToValibotSchema = ({ // Add transform to convert to BigInt const transformExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.transform, }), parameters: [ @@ -388,7 +433,7 @@ const numberTypeToValibotSchema = ({ // For regular number formats, use number schema const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.number, }), }); @@ -399,7 +444,7 @@ const numberTypeToValibotSchema = ({ if (!isBigInt && isInteger) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.integer, }), }); @@ -416,7 +461,7 @@ const numberTypeToValibotSchema = ({ // Add minimum value validation const minExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.minValue, }), parameters: [ @@ -434,7 +479,7 @@ const numberTypeToValibotSchema = ({ // Add maximum value validation const maxExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.maxValue, }), parameters: [ @@ -453,7 +498,7 @@ const numberTypeToValibotSchema = ({ if (schema.exclusiveMinimum !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.gtValue, }), parameters: [ @@ -464,7 +509,7 @@ const numberTypeToValibotSchema = ({ } else if (schema.minimum !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.minValue, }), parameters: [numberParameter({ isBigInt, value: schema.minimum })], @@ -475,7 +520,7 @@ const numberTypeToValibotSchema = ({ if (schema.exclusiveMaximum !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.ltValue, }), parameters: [ @@ -486,7 +531,7 @@ const numberTypeToValibotSchema = ({ } else if (schema.maximum !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.maxValue, }), parameters: [numberParameter({ isBigInt, value: schema.maximum })], @@ -494,7 +539,7 @@ const numberTypeToValibotSchema = ({ pipes.push(expression); } - return pipesToExpression(pipes); + return pipesToExpression({ pipes, plugin }); }; const objectTypeToValibotSchema = ({ @@ -546,12 +591,16 @@ const objectTypeToValibotSchema = ({ } properties.push( tsc.propertyAssignment({ - initializer: pipesToExpression(schemaPipes), + initializer: pipesToExpression({ pipes: schemaPipes, plugin }), name: propertyName, }), ); } + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + if ( schema.additionalProperties && schema.additionalProperties.type === 'object' && @@ -564,18 +613,18 @@ const objectTypeToValibotSchema = ({ }); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.record, }), parameters: [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.string, }), parameters: [], }), - pipesToExpression(pipes), + pipesToExpression({ pipes, plugin }), ], }); return { @@ -586,7 +635,7 @@ const objectTypeToValibotSchema = ({ const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.object, }), parameters: [ts.factory.createObjectLiteralExpression(properties, true)], @@ -599,14 +648,20 @@ const objectTypeToValibotSchema = ({ }; const stringTypeToValibotSchema = ({ + plugin, schema, }: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'string'>; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + if (typeof schema.const === 'string') { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.literal, }), parameters: [tsc.ots.string(schema.const)], @@ -618,7 +673,7 @@ const stringTypeToValibotSchema = ({ const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.string, }), }); @@ -630,7 +685,7 @@ const stringTypeToValibotSchema = ({ pipes.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.isoDate, }), }), @@ -640,7 +695,7 @@ const stringTypeToValibotSchema = ({ pipes.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.isoTimestamp, }), }), @@ -651,7 +706,7 @@ const stringTypeToValibotSchema = ({ pipes.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.ip, }), }), @@ -661,7 +716,7 @@ const stringTypeToValibotSchema = ({ pipes.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.url, }), }), @@ -673,7 +728,7 @@ const stringTypeToValibotSchema = ({ pipes.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: tsc.identifier({ text: schema.format }), }), }), @@ -685,7 +740,7 @@ const stringTypeToValibotSchema = ({ if (schema.minLength === schema.maxLength && schema.minLength !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.length, }), parameters: [tsc.valueToExpression({ value: schema.minLength })], @@ -695,7 +750,7 @@ const stringTypeToValibotSchema = ({ if (schema.minLength !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.minLength, }), parameters: [tsc.valueToExpression({ value: schema.minLength })], @@ -706,7 +761,7 @@ const stringTypeToValibotSchema = ({ if (schema.maxLength !== undefined) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.maxLength, }), parameters: [tsc.valueToExpression({ value: schema.maxLength })], @@ -718,7 +773,7 @@ const stringTypeToValibotSchema = ({ if (schema.pattern) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.regex, }), parameters: [tsc.regularExpressionLiteral({ text: schema.pattern })], @@ -726,7 +781,7 @@ const stringTypeToValibotSchema = ({ pipes.push(expression); } - return pipesToExpression(pipes); + return pipesToExpression({ pipes, plugin }); }; const tupleTypeToValibotSchema = ({ @@ -738,11 +793,15 @@ const tupleTypeToValibotSchema = ({ schema: SchemaWithType<'tuple'>; state: State; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + if (schema.const && Array.isArray(schema.const)) { const tupleElements = schema.const.map((value) => tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.literal, }), parameters: [tsc.valueToExpression({ value })], @@ -750,7 +809,7 @@ const tupleTypeToValibotSchema = ({ ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.tuple, }), parameters: [ @@ -769,11 +828,11 @@ const tupleTypeToValibotSchema = ({ schema: item, state, }); - return pipesToExpression(schemaPipes); + return pipesToExpression({ pipes: schemaPipes, plugin }); }); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.tuple, }), parameters: [ @@ -786,45 +845,64 @@ const tupleTypeToValibotSchema = ({ } return unknownTypeToValibotSchema({ + plugin, schema: { type: 'unknown', }, }); }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const undefinedTypeToValibotSchema = (_props: { +const undefinedTypeToValibotSchema = ({ + plugin, +}: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'undefined'>; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.undefined, }), }); return expression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const unknownTypeToValibotSchema = (_props: { +const unknownTypeToValibotSchema = ({ + plugin, +}: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'unknown'>; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.unknown, }), }); return expression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const voidTypeToValibotSchema = (_props: { +const voidTypeToValibotSchema = ({ + plugin, +}: { + plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'void'>; }) => { + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.void, }), }); @@ -855,12 +933,14 @@ const schemaTypeToValibotSchema = ({ case 'boolean': return { expression: booleanTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'boolean'>, }), }; case 'enum': return { expression: enumTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'enum'>, }), }; @@ -868,18 +948,21 @@ const schemaTypeToValibotSchema = ({ case 'number': return { expression: numberTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'integer' | 'number'>, }), }; case 'never': return { expression: neverTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'never'>, }), }; case 'null': return { expression: nullTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'null'>, }), }; @@ -894,12 +977,14 @@ const schemaTypeToValibotSchema = ({ if (schema.format === 'int64' || schema.format === 'uint64') { return { expression: numberTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'integer' | 'number'>, }), }; } return { expression: stringTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'string'>, }), }; @@ -914,18 +999,21 @@ const schemaTypeToValibotSchema = ({ case 'undefined': return { expression: undefinedTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'undefined'>, }), }; case 'unknown': return { expression: unknownTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'unknown'>, }), }; case 'void': return { expression: voidTypeToValibotSchema({ + plugin, schema: schema as SchemaWithType<'void'>, }), }; @@ -934,17 +1022,16 @@ const schemaTypeToValibotSchema = ({ export const schemaToValibotSchema = ({ $ref, - identifier: _identifier, optional, plugin, schema, state, + symbol, }: { /** * When $ref is supplied, a node will be emitted to the file. */ $ref?: string; - identifier?: Identifier; /** * Accept `optional` to handle optional object properties. We can't handle * this inside the object function because `.optional()` must come before @@ -954,45 +1041,46 @@ export const schemaToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: IR.SchemaObject; state: State; + symbol?: ICodegenSymbolOut; }): Array => { - // TODO: replace - const file = plugin.context.file({ id: valibotId })!; - // const f = plugin.gen.ensureFile(plugin.output); + const f = plugin.gen.ensureFile(plugin.output); let anyType: string | undefined; - let identifier: ReturnType | undefined = _identifier; let pipes: Array = []; if ($ref) { state.circularReferenceTracker.add($ref); - if (!identifier) { - identifier = file.identifier({ - $ref, - case: state.nameCase, - create: true, - nameTransformer: state.nameTransformer, - namespace: 'value', - }); - // TODO: claim unique name - // f.addSymbol({ name: '' }); + if (!symbol) { + const selector = plugin.api.getSelector('ref', $ref); + if (!plugin.gen.selectSymbolFirst(selector)) { + symbol = f.ensureSymbol({ + name: buildName({ + config: { + case: state.nameCase, + name: state.nameTransformer, + }, + name: refToName($ref), + }), + selector, + }); + } } } + const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'valibot'), + ); + if (schema.$ref) { const isCircularReference = state.circularReferenceTracker.has(schema.$ref); // if $ref hasn't been processed yet, inline it to avoid the // "Block-scoped variable used before its declaration." error // this could be (maybe?) fixed by reshuffling the generation order - let identifierRef = file.identifier({ - $ref: schema.$ref, - case: state.nameCase, - nameTransformer: state.nameTransformer, - namespace: 'value', - }); - - if (!identifierRef.name) { + const selector = plugin.api.getSelector('ref', schema.$ref); + let refSymbol = plugin.gen.selectSymbolFirst(selector); + if (!refSymbol) { const ref = plugin.context.resolveIrRef(schema.$ref); const schemaPipes = schemaToValibotSchema({ $ref: schema.$ref, @@ -1002,21 +1090,15 @@ export const schemaToValibotSchema = ({ }); pipes.push(...schemaPipes); - identifierRef = file.identifier({ - $ref: schema.$ref, - case: state.nameCase, - nameTransformer: state.nameTransformer, - namespace: 'value', - }); + refSymbol = plugin.gen.selectSymbolFirst(selector); } - // if `identifierRef.name` is falsy, we already set expression above - if (identifierRef.name) { - const refIdentifier = tsc.identifier({ text: identifierRef.name }); + if (refSymbol) { + const refIdentifier = tsc.identifier({ text: refSymbol.placeholder }); if (isCircularReference) { const lazyExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.lazy, }), parameters: [ @@ -1043,7 +1125,7 @@ export const schemaToValibotSchema = ({ if (plugin.config.metadata && schema.description) { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.metadata, }), parameters: [ @@ -1069,13 +1151,13 @@ export const schemaToValibotSchema = ({ schema: item, state, }); - return pipesToExpression(schemaPipes); + return pipesToExpression({ pipes: schemaPipes, plugin }); }); if (schema.logicalOperator === 'and') { const intersectExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.intersect, }), parameters: [ @@ -1088,7 +1170,7 @@ export const schemaToValibotSchema = ({ } else { const unionExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.union, }), parameters: [ @@ -1128,7 +1210,7 @@ export const schemaToValibotSchema = ({ if (schema.accessScope === 'read') { const readonlyExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.actions.readonly, }), }); @@ -1146,10 +1228,10 @@ export const schemaToValibotSchema = ({ pipes = [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.optional, }), - parameters: [pipesToExpression(pipes), callParameter], + parameters: [pipesToExpression({ pipes, plugin }), callParameter], }), ]; } @@ -1159,38 +1241,31 @@ export const schemaToValibotSchema = ({ pipes = [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: identifiers.schemas.optional, }), - parameters: [pipesToExpression(pipes)], + parameters: [pipesToExpression({ pipes, plugin })], }), ]; } } - // emit nodes only if $ref points to a reusable component - if (identifier && identifier.name && identifier.created) { + if (symbol) { const statement = tsc.constVariable({ comment: plugin.config.comments ? createSchemaComment({ schema }) : undefined, exportConst: true, - expression: pipesToExpression(pipes), - name: identifier.name, + expression: pipesToExpression({ pipes, plugin }), + name: symbol.placeholder, typeName: state.hasCircularReference ? (tsc.propertyAccessExpression({ - expression: identifiers.v, + expression: vSymbol.placeholder, name: anyType || identifiers.types.GenericSchema.text, }) as unknown as ts.TypeNode) : undefined, }); - file.add(statement); - // TODO: update claimed name - // f.addSymbol({ - // name: identifier.name, - // value: statement, - // }); - + symbol.update({ value: statement }); return []; } @@ -1198,23 +1273,17 @@ export const schemaToValibotSchema = ({ }; export const handler: ValibotPlugin['Handler'] = ({ plugin }) => { - const file = plugin.createFile({ - case: plugin.config.case, - id: valibotId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); - // const f = plugin.gen.createFile(plugin.output, { - // extension: '.ts', - // path: '{{path}}.gen', - // renderer: new TypeScriptRenderer(), - // }); - - file.import({ - alias: identifiers.v.text, - module: 'valibot', - name: '*', + + const vSymbol = f.ensureSymbol({ + name: 'v', + selector: plugin.api.getSelector('import', 'valibot'), }); - // f.addImport({ from: 'valibot', namespaceImport: identifiers.v.text }); + f.addImport({ from: 'valibot', namespaceImport: vSymbol.placeholder }); plugin.forEach( 'operation', @@ -1230,45 +1299,51 @@ export const handler: ValibotPlugin['Handler'] = ({ plugin }) => { nameTransformer: plugin.config.definitions.name, }; - if (event.type === 'operation') { - operationToValibotSchema({ - operation: event.operation, - plugin, - state, - }); - } else if (event.type === 'parameter') { - schemaToValibotSchema({ - $ref: event.$ref, - plugin, - schema: event.parameter.schema, - state, - }); - } else if (event.type === 'requestBody') { - schemaToValibotSchema({ - $ref: event.$ref, - plugin, - schema: event.requestBody.schema, - state, - }); - } else if (event.type === 'schema') { - schemaToValibotSchema({ - $ref: event.$ref, - plugin, - schema: event.schema, - state, - }); - } else if (event.type === 'webhook') { - webhookToValibotSchema({ - operation: event.operation, - plugin, - state, - }); + switch (event.type) { + case 'operation': + operationToValibotSchema({ + operation: event.operation, + plugin, + state, + }); + break; + case 'parameter': + schemaToValibotSchema({ + $ref: event.$ref, + plugin, + schema: event.parameter.schema, + state, + }); + break; + case 'requestBody': + schemaToValibotSchema({ + $ref: event.$ref, + plugin, + schema: event.requestBody.schema, + state, + }); + break; + case 'schema': + schemaToValibotSchema({ + $ref: event.$ref, + plugin, + schema: event.schema, + state, + }); + break; + case 'webhook': + webhookToValibotSchema({ + operation: event.operation, + plugin, + state, + }); + break; } }, ); - // if (plugin.config.exportFromIndex && f.hasContent()) { - // const index = plugin.gen.ensureFile('index'); - // index.addExport({ from: f, namespaceImport: true }); - // } + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/packages/openapi-ts/src/plugins/valibot/types.d.ts b/packages/openapi-ts/src/plugins/valibot/types.d.ts index 118757571..77aa179e6 100644 --- a/packages/openapi-ts/src/plugins/valibot/types.d.ts +++ b/packages/openapi-ts/src/plugins/valibot/types.d.ts @@ -1,6 +1,6 @@ import type { StringCase, StringName } from '../../types/case'; import type { DefinePlugin, Plugin } from '../types'; -import type { Api } from './api'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'valibot'> & { /** @@ -322,4 +322,4 @@ export type Config = Plugin.Name<'valibot'> & { }; }; -export type ValibotPlugin = DefinePlugin; +export type ValibotPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/valibot/webhook.ts b/packages/openapi-ts/src/plugins/valibot/webhook.ts index 954805ebf..0aae05ee4 100644 --- a/packages/openapi-ts/src/plugins/valibot/webhook.ts +++ b/packages/openapi-ts/src/plugins/valibot/webhook.ts @@ -1,5 +1,5 @@ import type { IR } from '../../ir/types'; -import { valibotId } from './constants'; +import { buildName } from '../../openApi/shared/utils/name'; import { schemaToValibotSchema, type State } from './plugin'; import type { ValibotPlugin } from './types'; @@ -12,8 +12,6 @@ export const webhookToValibotSchema = ({ plugin: ValibotPlugin['Instance']; state: State; }) => { - const file = plugin.context.file({ id: valibotId })!; - if (plugin.config.webhooks.enabled) { const requiredProperties = new Set(); @@ -112,21 +110,20 @@ export const webhookToValibotSchema = ({ schemaData.required = [...requiredProperties]; - const identifierData = file.identifier({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/valibot-webhook/${operation.id}`, - case: plugin.config.webhooks.case, - create: true, - nameTransformer: plugin.config.webhooks.name, - namespace: 'value', + const selector = plugin.api.getSelector('webhook-request', operation.id); + const name = buildName({ + config: plugin.config.webhooks, + name: operation.id, }); + const f = plugin.gen.ensureFile(plugin.output); + const symbol = f.addSymbol({ name, selector }); schemaToValibotSchema({ // TODO: refactor for better cross-plugin compatibility $ref: `#/valibot-webhook/${operation.id}`, - identifier: identifierData, plugin, schema: schemaData, state, + symbol, }); } }; diff --git a/packages/openapi-ts/src/plugins/zod/api.ts b/packages/openapi-ts/src/plugins/zod/api.ts index 7b47b78e0..2e938cfaf 100644 --- a/packages/openapi-ts/src/plugins/zod/api.ts +++ b/packages/openapi-ts/src/plugins/zod/api.ts @@ -1,153 +1,140 @@ +import type { + ICodegenFile, + ICodegenSymbolSelector, +} from '@hey-api/codegen-core'; import type ts from 'typescript'; -import type { GeneratedFile } from '../../generate/file'; import type { IR } from '../../ir/types'; import { tsc } from '../../tsc'; -import { identifiers, zodId } from './constants'; +import type { Plugin } from '../types'; +import { identifiers } from './constants'; import type { ZodPlugin } from './types'; -const createRequestValidator = ({ - file, - operation, - plugin, -}: { - file: GeneratedFile; +type SelectorType = + | 'data' + | 'import' + | 'ref' + | 'responses' + | 'type-infer-data' + | 'type-infer-ref' + | 'type-infer-responses' + | 'type-infer-webhook-request' + | 'webhook-request'; + +type ValidatorArgs = { + file: ICodegenFile; operation: IR.OperationObject; plugin: ZodPlugin['Instance']; -}): ts.ArrowFunction | undefined => { - const zodFile = plugin.context.file({ id: zodId })!; - const name = zodFile.getName(plugin.api.getId({ operation, type: 'data' })); - if (!name) return; +}; + +export type IApi = { + createRequestValidator: (args: ValidatorArgs) => ts.ArrowFunction | undefined; + createResponseValidator: ( + args: ValidatorArgs, + ) => ts.ArrowFunction | undefined; + /** + * @param type Selector type. + * @param value Depends on `type`: + * - `data`: `operation.id` string + * - `import`: headless symbols representing module imports + * - `ref`: `$ref` JSON pointer + * - `responses`: `operation.id` string + * - `type-infer-data`: `operation.id` string + * - `type-infer-ref`: `$ref` JSON pointer + * - `type-infer-responses`: `operation.id` string + * - `type-infer-webhook-request`: `operation.id` string + * - `webhook-request`: `operation.id` string + * @returns Selector array + */ + getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; +}; + +export class Api implements IApi { + constructor(public meta: Plugin.Name<'zod'>) {} - file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: zodId, - }), - name, - }); + createRequestValidator({ + file, + operation, + plugin, + }: ValidatorArgs): ts.ArrowFunction | undefined { + const symbol = plugin.gen.selectSymbolFirst( + plugin.api.getSelector('data', operation.id), + ); + if (!symbol) return; - const dataParameterName = 'data'; + file.addImport({ + from: symbol.file, + names: [symbol.placeholder], + }); - return tsc.arrowFunction({ - async: true, - parameters: [ - { - name: dataParameterName, - }, - ], - statements: [ - tsc.returnStatement({ - expression: tsc.awaitExpression({ - expression: tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: tsc.identifier({ text: name }), - name: identifiers.parseAsync, + const dataParameterName = 'data'; + + return tsc.arrowFunction({ + async: true, + parameters: [ + { + name: dataParameterName, + }, + ], + statements: [ + tsc.returnStatement({ + expression: tsc.awaitExpression({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: symbol.placeholder, + name: identifiers.parseAsync, + }), + parameters: [tsc.identifier({ text: dataParameterName })], }), - parameters: [tsc.identifier({ text: dataParameterName })], }), }), - }), - ], - }); -}; + ], + }); + } -const createResponseValidator = ({ - file, - operation, - plugin, -}: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: ZodPlugin['Instance']; -}): ts.ArrowFunction | undefined => { - const zodFile = plugin.context.file({ id: zodId })!; - const name = zodFile.getName( - plugin.api.getId({ operation, type: 'responses' }), - ); - if (!name) return; + createResponseValidator({ + file, + operation, + plugin, + }: ValidatorArgs): ts.ArrowFunction | undefined { + const symbol = plugin.gen.selectSymbolFirst( + plugin.api.getSelector('responses', operation.id), + ); + if (!symbol) return; - file.import({ - module: file.relativePathToFile({ - context: plugin.context, - id: zodId, - }), - name, - }); + file.addImport({ + from: symbol.file, + names: [symbol.placeholder], + }); - const dataParameterName = 'data'; + const dataParameterName = 'data'; - return tsc.arrowFunction({ - async: true, - parameters: [ - { - name: dataParameterName, - }, - ], - statements: [ - tsc.returnStatement({ - expression: tsc.awaitExpression({ - expression: tsc.callExpression({ - functionName: tsc.propertyAccessExpression({ - expression: tsc.identifier({ text: name }), - name: identifiers.parseAsync, + return tsc.arrowFunction({ + async: true, + parameters: [ + { + name: dataParameterName, + }, + ], + statements: [ + tsc.returnStatement({ + expression: tsc.awaitExpression({ + expression: tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: symbol.placeholder, + name: identifiers.parseAsync, + }), + parameters: [tsc.identifier({ text: dataParameterName })], }), - parameters: [tsc.identifier({ text: dataParameterName })], }), }), - }), - ], - }); -}; - -type GetIdArgs = - | { - operation: IR.OperationObject; - type: - | 'data' - | 'responses' - | 'type-infer-data' - | 'type-infer-responses' - | 'type-infer-webhook-request' - | 'webhook-request'; - } - | { - type: 'ref' | 'type-infer-ref'; - value: string; - }; - -const getId = (args: GetIdArgs): string => { - switch (args.type) { - case 'data': - case 'responses': - case 'type-infer-data': - case 'type-infer-responses': - case 'type-infer-webhook-request': - case 'webhook-request': - return `${args.operation.id}-${args.type}`; - case 'ref': - case 'type-infer-ref': - default: - return `${args.type}-${args.value}`; + ], + }); } -}; -export type Api = { - createRequestValidator: (args: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: ZodPlugin['Instance']; - }) => ts.ArrowFunction | undefined; - createResponseValidator: (args: { - file: GeneratedFile; - operation: IR.OperationObject; - plugin: ZodPlugin['Instance']; - }) => ts.ArrowFunction | undefined; - getId: (args: GetIdArgs) => string; -}; - -export const api: Api = { - createRequestValidator, - createResponseValidator, - getId, -}; + getSelector( + ...args: ReadonlyArray + ): ICodegenSymbolSelector { + return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + } +} diff --git a/packages/openapi-ts/src/plugins/zod/config.ts b/packages/openapi-ts/src/plugins/zod/config.ts index 435fc7550..585fb1f5a 100644 --- a/packages/openapi-ts/src/plugins/zod/config.ts +++ b/packages/openapi-ts/src/plugins/zod/config.ts @@ -1,7 +1,7 @@ import colors from 'ansi-colors'; import { definePluginConfig, mappers } from '../shared/utils/config'; -import { api } from './api'; +import { Api } from './api'; import { handler } from './plugin'; import type { ZodPlugin } from './types'; @@ -10,7 +10,9 @@ type CompatibilityVersion = NonNullable< >; export const defaultConfig: ZodPlugin['Config'] = { - api, + api: new Api({ + name: 'zod', + }), config: { case: 'camelCase', comments: true, diff --git a/packages/openapi-ts/src/plugins/zod/constants.ts b/packages/openapi-ts/src/plugins/zod/constants.ts index f46558180..5fbf81c8e 100644 --- a/packages/openapi-ts/src/plugins/zod/constants.ts +++ b/packages/openapi-ts/src/plugins/zod/constants.ts @@ -55,7 +55,4 @@ export const identifiers = { url: tsc.identifier({ text: 'url' }), uuid: tsc.identifier({ text: 'uuid' }), void: tsc.identifier({ text: 'void' }), - z: tsc.identifier({ text: 'z' }), }; - -export const zodId = 'zod'; diff --git a/packages/openapi-ts/src/plugins/zod/export.ts b/packages/openapi-ts/src/plugins/zod/export.ts index 4cf43bd4d..676229b4f 100644 --- a/packages/openapi-ts/src/plugins/zod/export.ts +++ b/packages/openapi-ts/src/plugins/zod/export.ts @@ -1,67 +1,62 @@ +import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { IR } from '../../ir/types'; import { tsc } from '../../tsc'; import { createSchemaComment } from '../shared/utils/schema'; -import { identifiers, zodId } from './constants'; +import { identifiers } from './constants'; import type { ZodSchema } from './shared/types'; import type { ZodPlugin } from './types'; export const exportZodSchema = ({ plugin, schema, - schemaId, - typeInferId, + symbol, + typeInferSymbol, zodSchema, }: { plugin: ZodPlugin['Instance']; schema: IR.SchemaObject; - schemaId: string; - typeInferId: string | undefined; + symbol: ICodegenSymbolOut; + typeInferSymbol: ICodegenSymbolOut | undefined; zodSchema: ZodSchema; }) => { - const file = plugin.context.file({ id: zodId })!; - const node = file.addNodeReference(schemaId, { - factory: (typeName) => tsc.typeReferenceNode({ typeName }), - }); + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const statement = tsc.constVariable({ comment: plugin.config.comments ? createSchemaComment({ schema }) : undefined, exportConst: true, expression: zodSchema.expression, - name: node, + name: symbol.placeholder, typeName: zodSchema.typeName ? (tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: zodSchema.typeName, }) as unknown as ts.TypeNode) : undefined, }); - file.add(statement); + symbol.update({ value: statement }); - if (typeInferId) { - const inferNode = file.addNodeReference(typeInferId, { - factory: (typeName) => tsc.typeReferenceNode({ typeName }), - }); - const nodeIdentifier = file.addNodeReference(schemaId, { - factory: (text) => tsc.identifier({ text }), - }); + if (typeInferSymbol) { const inferType = tsc.typeAliasDeclaration({ exportType: true, - name: inferNode, + name: typeInferSymbol.placeholder, type: tsc.typeReferenceNode({ typeArguments: [ tsc.typeOfExpression({ - text: nodeIdentifier, + text: symbol.placeholder, }) as unknown as ts.TypeNode, ], typeName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.infer, }) as unknown as string, }), }); - file.add(inferType); + typeInferSymbol.update({ value: inferType }); } }; diff --git a/packages/openapi-ts/src/plugins/zod/mini/plugin.ts b/packages/openapi-ts/src/plugins/zod/mini/plugin.ts index df8a91a4b..0eac8ea88 100644 --- a/packages/openapi-ts/src/plugins/zod/mini/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/mini/plugin.ts @@ -1,12 +1,13 @@ import ts from 'typescript'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import { deduplicateSchema } from '../../../ir/schema'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { refToName } from '../../../utils/ref'; import { numberRegExp } from '../../../utils/regexp'; -import { identifiers, zodId } from '../constants'; +import { identifiers } from '../constants'; import { exportZodSchema } from '../export'; import { getZodModule } from '../shared/module'; import { operationToZodSchema } from '../shared/operation'; @@ -23,10 +24,14 @@ const arrayTypeToZodSchema = ({ schema: SchemaWithType<'array'>; state: State; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const result: Partial> = {}; const functionName = tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.array, }); @@ -35,6 +40,7 @@ const arrayTypeToZodSchema = ({ functionName, parameters: [ unknownTypeToZodSchema({ + plugin, schema: { type: 'unknown', }, @@ -72,13 +78,13 @@ const arrayTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.array, }), parameters: [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.union, }), parameters: [ @@ -98,7 +104,7 @@ const arrayTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.length, }), parameters: [tsc.valueToExpression({ value: schema.minItems })], @@ -109,7 +115,7 @@ const arrayTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.minLength, }), parameters: [tsc.valueToExpression({ value: schema.minItems })], @@ -121,7 +127,7 @@ const arrayTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.maxLength, }), parameters: [tsc.valueToExpression({ value: schema.maxItems })], @@ -144,16 +150,22 @@ const arrayTypeToZodSchema = ({ }; const booleanTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'boolean'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const result: Partial> = {}; if (typeof schema.const === 'boolean') { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.boolean(schema.const)], @@ -163,7 +175,7 @@ const booleanTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.boolean, }), }); @@ -171,10 +183,16 @@ const booleanTypeToZodSchema = ({ }; const enumTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'enum'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const result: Partial> = {}; const enumMembers: Array = []; @@ -196,6 +214,7 @@ const enumTypeToZodSchema = ({ if (!enumMembers.length) { return unknownTypeToZodSchema({ + plugin, schema: { type: 'unknown', }, @@ -204,7 +223,7 @@ const enumTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.enum, }), parameters: [ @@ -218,7 +237,7 @@ const enumTypeToZodSchema = ({ if (isNullable) { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.nullable, }), parameters: [result.expression], @@ -228,28 +247,38 @@ const enumTypeToZodSchema = ({ return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const neverTypeToZodSchema = (_props: { +const neverTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'never'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const result: Partial> = {}; result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.never, }), }); return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const nullTypeToZodSchema = (_props: { +const nullTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'null'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const result: Partial> = {}; result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.null, }), }); @@ -282,10 +311,16 @@ const numberParameter = ({ }; const numberTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'integer' | 'number'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const result: Partial> = {}; const isBigInt = schema.type === 'integer' && schema.format === 'int64'; @@ -294,7 +329,7 @@ const numberTypeToZodSchema = ({ // TODO: parser - handle bigint constants result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.number(schema.const)], @@ -306,13 +341,13 @@ const numberTypeToZodSchema = ({ functionName: isBigInt ? tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.coerce, }), name: identifiers.bigint, }) : tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.number, }), }); @@ -320,7 +355,7 @@ const numberTypeToZodSchema = ({ if (!isBigInt && schema.type === 'integer') { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.int, }), }); @@ -332,7 +367,7 @@ const numberTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.gt, }), parameters: [ @@ -344,7 +379,7 @@ const numberTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.gte, }), parameters: [numberParameter({ isBigInt, value: schema.minimum })], @@ -356,7 +391,7 @@ const numberTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.lt, }), parameters: [ @@ -368,7 +403,7 @@ const numberTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.lte, }), parameters: [numberParameter({ isBigInt, value: schema.maximum })], @@ -398,6 +433,10 @@ const objectTypeToZodSchema = ({ schema: SchemaWithType<'object'>; state: State; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const result: Partial> = {}; // TODO: parser - handle constants @@ -447,7 +486,7 @@ const objectTypeToZodSchema = ({ // @ts-expect-error returnType: propertySchema.typeName ? tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: propertySchema.typeName, }) : undefined, @@ -479,13 +518,13 @@ const objectTypeToZodSchema = ({ }); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.record, }), parameters: [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.string, }), parameters: [], @@ -501,7 +540,7 @@ const objectTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.object, }), parameters: [ts.factory.createObjectLiteralExpression(properties, true)], @@ -517,12 +556,16 @@ const stringTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'string'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const result: Partial> = {}; if (typeof schema.const === 'string') { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.string(schema.const)], @@ -532,7 +575,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.string, }), }); @@ -552,7 +595,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.iso, }), name: identifiers.date, @@ -563,7 +606,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.iso, }), name: identifiers.datetime, @@ -581,7 +624,7 @@ const stringTypeToZodSchema = ({ case 'email': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.email, }), }); @@ -589,7 +632,7 @@ const stringTypeToZodSchema = ({ case 'ipv4': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.ipv4, }), }); @@ -597,7 +640,7 @@ const stringTypeToZodSchema = ({ case 'ipv6': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.ipv6, }), }); @@ -606,7 +649,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.iso, }), name: identifiers.time, @@ -616,7 +659,7 @@ const stringTypeToZodSchema = ({ case 'uri': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.url, }), }); @@ -624,7 +667,7 @@ const stringTypeToZodSchema = ({ case 'uuid': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.uuid, }), }); @@ -638,7 +681,7 @@ const stringTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.length, }), parameters: [tsc.valueToExpression({ value: schema.minLength })], @@ -649,7 +692,7 @@ const stringTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.minLength, }), parameters: [tsc.valueToExpression({ value: schema.minLength })], @@ -661,7 +704,7 @@ const stringTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.maxLength, }), parameters: [tsc.valueToExpression({ value: schema.maxLength })], @@ -674,7 +717,7 @@ const stringTypeToZodSchema = ({ checks.push( tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.regex, }), parameters: [tsc.regularExpressionLiteral({ text: schema.pattern })], @@ -704,13 +747,17 @@ const tupleTypeToZodSchema = ({ schema: SchemaWithType<'tuple'>; state: State; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const result: Partial> = {}; if (schema.const && Array.isArray(schema.const)) { const tupleElements = schema.const.map((value) => tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.valueToExpression({ value })], @@ -718,7 +765,7 @@ const tupleTypeToZodSchema = ({ ); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.tuple, }), parameters: [ @@ -747,7 +794,7 @@ const tupleTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.tuple, }), parameters: [ @@ -760,42 +807,57 @@ const tupleTypeToZodSchema = ({ return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const undefinedTypeToZodSchema = (_props: { +const undefinedTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'undefined'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const result: Partial> = {}; result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.undefined, }), }); return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const unknownTypeToZodSchema = (_props: { +const unknownTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'unknown'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const result: Partial> = {}; result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.unknown, }), }); return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const voidTypeToZodSchema = (_props: { +const voidTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'void'>; }): Omit => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const result: Partial> = {}; result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.void, }), }); @@ -820,23 +882,28 @@ const schemaTypeToZodSchema = ({ }); case 'boolean': return booleanTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'boolean'>, }); case 'enum': return enumTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'enum'>, }); case 'integer': case 'number': return numberTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'integer' | 'number'>, }); case 'never': return neverTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'never'>, }); case 'null': return nullTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'null'>, }); case 'object': @@ -858,14 +925,17 @@ const schemaTypeToZodSchema = ({ }); case 'undefined': return undefinedTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'undefined'>, }); case 'unknown': return unknownTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'unknown'>, }); case 'void': return voidTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'void'>, }); } @@ -887,10 +957,14 @@ const schemaToZodSchema = ({ schema: IR.SchemaObject; state: State; }): ZodSchema => { - const file = plugin.context.file({ id: zodId })!; + const f = plugin.gen.ensureFile(plugin.output); let zodSchema: Partial = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (schema.$ref) { const isCircularReference = state.circularReferenceTracker.includes( schema.$ref, @@ -899,30 +973,36 @@ const schemaToZodSchema = ({ state.circularReferenceTracker.push(schema.$ref); state.currentReferenceTracker.push(schema.$ref); - const id = plugin.api.getId({ type: 'ref', value: schema.$ref }); + const selector = plugin.api.getSelector('ref', schema.$ref); + let symbol = plugin.gen.selectSymbolFirst(selector); if (isCircularReference) { - const expression = file.addNodeReference(id, { - factory: (text) => tsc.identifier({ text }), - }); + if (!symbol) { + symbol = f.ensureSymbol({ selector }); + } + if (isSelfReference) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.lazy, }), parameters: [ tsc.arrowFunction({ returnType: tsc.keywordTypeNode({ keyword: 'any' }), - statements: [tsc.returnStatement({ expression })], + statements: [ + tsc.returnStatement({ + expression: tsc.identifier({ text: symbol.placeholder }), + }), + ], }), ], }); } else { - zodSchema.expression = expression; + zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); } zodSchema.hasCircularReference = true; - } else if (!file.getName(id)) { + } else if (!symbol) { // if $ref hasn't been processed yet, inline it to avoid the // "Block-scoped variable used before its declaration." error // this could be (maybe?) fixed by reshuffling the generation order @@ -936,10 +1016,8 @@ const schemaToZodSchema = ({ } if (!isCircularReference) { - const expression = file.addNodeReference(id, { - factory: (text) => tsc.identifier({ text }), - }); - zodSchema.expression = expression; + const symbol = plugin.gen.selectSymbolFirstOrThrow(selector); + zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); } state.circularReferenceTracker.pop(); @@ -957,7 +1035,7 @@ const schemaToZodSchema = ({ }), parameters: [ tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.globalRegistry, }), tsc.objectExpression({ @@ -995,7 +1073,7 @@ const schemaToZodSchema = ({ ) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.intersection, }), parameters: itemTypes, @@ -1005,7 +1083,7 @@ const schemaToZodSchema = ({ itemTypes.slice(1).forEach((item) => { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.intersection, }), parameters: [zodSchema.expression, item], @@ -1015,7 +1093,7 @@ const schemaToZodSchema = ({ } else { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.union, }), parameters: [ @@ -1044,7 +1122,7 @@ const schemaToZodSchema = ({ if (schema.accessScope === 'read') { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.readonly, }), parameters: [zodSchema.expression], @@ -1054,7 +1132,7 @@ const schemaToZodSchema = ({ if (optional) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.optional, }), parameters: [zodSchema.expression], @@ -1071,7 +1149,7 @@ const schemaToZodSchema = ({ if (callParameter) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers._default, }), parameters: [zodSchema.expression, callParameter], @@ -1101,52 +1179,55 @@ const handleComponent = ({ currentReferenceTracker: [id], }; - const file = plugin.context.file({ id: zodId })!; - const schemaId = plugin.api.getId({ type: 'ref', value: id }); - - if (file.getName(schemaId)) return; + const selector = plugin.api.getSelector('ref', id); + let symbol = plugin.gen.selectSymbolFirst(selector); + if (symbol && !symbol.headless) return; const zodSchema = schemaToZodSchema({ plugin, schema, state }); - const typeInferId = plugin.config.definitions.types.infer.enabled - ? plugin.api.getId({ type: 'type-infer-ref', value: id }) + const f = plugin.gen.ensureFile(plugin.output); + const baseName = refToName(id); + symbol = f.ensureSymbol({ selector }); + symbol = symbol.update({ + name: buildName({ + config: plugin.config.definitions, + name: baseName, + }), + }); + const typeInferSymbol = plugin.config.definitions.types.infer.enabled + ? f.addSymbol({ + name: buildName({ + config: plugin.config.definitions.types.infer, + name: baseName, + }), + selector: plugin.api.getSelector('type-infer-ref', id), + }) : undefined; exportZodSchema({ plugin, schema, - schemaId, - typeInferId, + symbol, + typeInferSymbol, zodSchema, }); - const baseName = refToName(id); - file.updateNodeReferences( - schemaId, - buildName({ - config: plugin.config.definitions, - name: baseName, - }), - ); - if (typeInferId) { - file.updateNodeReferences( - typeInferId, - buildName({ - config: plugin.config.definitions.types.infer, - name: baseName, - }), - ); - } }; export const handlerMini: ZodPlugin['Handler'] = ({ plugin }) => { - const file = plugin.createFile({ - case: plugin.config.case, - id: zodId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); - file.import({ - alias: identifiers.z.text, - module: getZodModule({ plugin }), - name: '*', + const zSymbol = f.ensureSymbol({ + name: 'z', + selector: plugin.api.getSelector('import', 'zod'), + }); + f.addImport({ + aliases: { + z: zSymbol.placeholder, + }, + from: getZodModule({ plugin }), + names: ['z'], }); plugin.forEach( @@ -1156,51 +1237,62 @@ export const handlerMini: ZodPlugin['Handler'] = ({ plugin }) => { 'schema', 'webhook', (event) => { - if (event.type === 'operation') { - operationToZodSchema({ - getZodSchema: (schema) => { - const state: State = { - circularReferenceTracker: [], - currentReferenceTracker: [], - hasCircularReference: false, - }; - return schemaToZodSchema({ plugin, schema, state }); - }, - operation: event.operation, - plugin, - }); - } else if (event.type === 'parameter') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.parameter.schema, - }); - } else if (event.type === 'requestBody') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.requestBody.schema, - }); - } else if (event.type === 'schema') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.schema, - }); - } else if (event.type === 'webhook') { - webhookToZodSchema({ - getZodSchema: (schema) => { - const state: State = { - circularReferenceTracker: [], - currentReferenceTracker: [], - hasCircularReference: false, - }; - return schemaToZodSchema({ plugin, schema, state }); - }, - operation: event.operation, - plugin, - }); + switch (event.type) { + case 'operation': + operationToZodSchema({ + getZodSchema: (schema) => { + const state: State = { + circularReferenceTracker: [], + currentReferenceTracker: [], + hasCircularReference: false, + }; + return schemaToZodSchema({ plugin, schema, state }); + }, + operation: event.operation, + plugin, + }); + break; + case 'parameter': + handleComponent({ + id: event.$ref, + plugin, + schema: event.parameter.schema, + }); + break; + case 'requestBody': + handleComponent({ + id: event.$ref, + plugin, + schema: event.requestBody.schema, + }); + break; + case 'schema': + handleComponent({ + id: event.$ref, + plugin, + schema: event.schema, + }); + break; + case 'webhook': + webhookToZodSchema({ + getZodSchema: (schema) => { + const state: State = { + circularReferenceTracker: [], + currentReferenceTracker: [], + hasCircularReference: false, + }; + return schemaToZodSchema({ plugin, schema, state }); + }, + operation: event.operation, + plugin, + }); + break; } }, ); + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/packages/openapi-ts/src/plugins/zod/shared/operation.ts b/packages/openapi-ts/src/plugins/zod/shared/operation.ts index 5bed8b75a..89215872d 100644 --- a/packages/openapi-ts/src/plugins/zod/shared/operation.ts +++ b/packages/openapi-ts/src/plugins/zod/shared/operation.ts @@ -1,7 +1,6 @@ import { operationResponsesMap } from '../../../ir/operation'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; -import { zodId } from '../constants'; import { exportZodSchema } from '../export'; import type { ZodPlugin } from '../types'; import type { ZodSchema } from './types'; @@ -15,7 +14,7 @@ export const operationToZodSchema = ({ operation: IR.OperationObject; plugin: ZodPlugin['Instance']; }) => { - const file = plugin.context.file({ id: zodId })!; + const f = plugin.gen.ensureFile(plugin.output); if (plugin.config.requests.enabled) { const requiredProperties = new Set(); @@ -116,33 +115,29 @@ export const operationToZodSchema = ({ schemaData.required = [...requiredProperties]; const zodSchema = getZodSchema(schemaData); - const schemaId = plugin.api.getId({ operation, type: 'data' }); - const typeInferId = plugin.config.requests.types.infer.enabled - ? plugin.api.getId({ operation, type: 'type-infer-data' }) + const symbol = f.addSymbol({ + name: buildName({ + config: plugin.config.requests, + name: operation.id, + }), + selector: plugin.api.getSelector('data', operation.id), + }); + const typeInferSymbol = plugin.config.requests.types.infer.enabled + ? f.addSymbol({ + name: buildName({ + config: plugin.config.requests.types.infer, + name: operation.id, + }), + selector: plugin.api.getSelector('type-infer-data', operation.id), + }) : undefined; exportZodSchema({ plugin, schema: schemaData, - schemaId, - typeInferId, + symbol, + typeInferSymbol, zodSchema, }); - file.updateNodeReferences( - schemaId, - buildName({ - config: plugin.config.requests, - name: operation.id, - }), - ); - if (typeInferId) { - file.updateNodeReferences( - typeInferId, - buildName({ - config: plugin.config.requests.types.infer, - name: operation.id, - }), - ); - } } if (plugin.config.responses.enabled) { @@ -151,33 +146,32 @@ export const operationToZodSchema = ({ if (response) { const zodSchema = getZodSchema(response); - const schemaId = plugin.api.getId({ operation, type: 'responses' }); - const typeInferId = plugin.config.responses.types.infer.enabled - ? plugin.api.getId({ operation, type: 'type-infer-responses' }) + const symbol = f.addSymbol({ + name: buildName({ + config: plugin.config.responses, + name: operation.id, + }), + selector: plugin.api.getSelector('responses', operation.id), + }); + const typeInferSymbol = plugin.config.responses.types.infer.enabled + ? f.addSymbol({ + name: buildName({ + config: plugin.config.responses.types.infer, + name: operation.id, + }), + selector: plugin.api.getSelector( + 'type-infer-responses', + operation.id, + ), + }) : undefined; exportZodSchema({ plugin, schema: response, - schemaId, - typeInferId, + symbol, + typeInferSymbol, zodSchema, }); - file.updateNodeReferences( - schemaId, - buildName({ - config: plugin.config.responses, - name: operation.id, - }), - ); - if (typeInferId) { - file.updateNodeReferences( - typeInferId, - buildName({ - config: plugin.config.responses.types.infer, - name: operation.id, - }), - ); - } } } } diff --git a/packages/openapi-ts/src/plugins/zod/shared/webhook.ts b/packages/openapi-ts/src/plugins/zod/shared/webhook.ts index d014899dd..5e8374943 100644 --- a/packages/openapi-ts/src/plugins/zod/shared/webhook.ts +++ b/packages/openapi-ts/src/plugins/zod/shared/webhook.ts @@ -1,6 +1,5 @@ import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; -import { zodId } from '../constants'; import { exportZodSchema } from '../export'; import type { ZodPlugin } from '../types'; import type { ZodSchema } from './types'; @@ -14,7 +13,7 @@ export const webhookToZodSchema = ({ operation: IR.OperationObject; plugin: ZodPlugin['Instance']; }) => { - const file = plugin.context.file({ id: zodId })!; + const f = plugin.gen.ensureFile(plugin.output); if (plugin.config.webhooks.enabled) { const requiredProperties = new Set(); @@ -115,32 +114,31 @@ export const webhookToZodSchema = ({ schemaData.required = [...requiredProperties]; const zodSchema = getZodSchema(schemaData); - const schemaId = plugin.api.getId({ operation, type: 'webhook-request' }); - const typeInferId = plugin.config.webhooks.types.infer.enabled - ? plugin.api.getId({ operation, type: 'type-infer-webhook-request' }) + const symbol = f.addSymbol({ + name: buildName({ + config: plugin.config.webhooks, + name: operation.id, + }), + selector: plugin.api.getSelector('webhook-request', operation.id), + }); + const typeInferSymbol = plugin.config.webhooks.types.infer.enabled + ? f.addSymbol({ + name: buildName({ + config: plugin.config.webhooks.types.infer, + name: operation.id, + }), + selector: plugin.api.getSelector( + 'type-infer-webhook-request', + operation.id, + ), + }) : undefined; exportZodSchema({ plugin, schema: schemaData, - schemaId, - typeInferId, + symbol, + typeInferSymbol, zodSchema, }); - file.updateNodeReferences( - schemaId, - buildName({ - config: plugin.config.webhooks, - name: operation.id, - }), - ); - if (typeInferId) { - file.updateNodeReferences( - typeInferId, - buildName({ - config: plugin.config.webhooks.types.infer, - name: operation.id, - }), - ); - } } }; diff --git a/packages/openapi-ts/src/plugins/zod/types.d.ts b/packages/openapi-ts/src/plugins/zod/types.d.ts index 679702b7f..df4eb05e0 100644 --- a/packages/openapi-ts/src/plugins/zod/types.d.ts +++ b/packages/openapi-ts/src/plugins/zod/types.d.ts @@ -1,6 +1,6 @@ import type { StringCase, StringName } from '../../types/case'; import type { DefinePlugin, Plugin } from '../types'; -import type { Api } from './api'; +import type { IApi } from './api'; export type UserConfig = Plugin.Name<'zod'> & { /** @@ -748,4 +748,4 @@ export type Config = Plugin.Name<'zod'> & { }; }; -export type ZodPlugin = DefinePlugin; +export type ZodPlugin = DefinePlugin; diff --git a/packages/openapi-ts/src/plugins/zod/v3/plugin.ts b/packages/openapi-ts/src/plugins/zod/v3/plugin.ts index fa265b87e..3766c48b8 100644 --- a/packages/openapi-ts/src/plugins/zod/v3/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/v3/plugin.ts @@ -1,12 +1,13 @@ import ts from 'typescript'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import { deduplicateSchema } from '../../../ir/schema'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { refToName } from '../../../utils/ref'; import { numberRegExp } from '../../../utils/regexp'; -import { identifiers, zodId } from '../constants'; +import { identifiers } from '../constants'; import { exportZodSchema } from '../export'; import { getZodModule } from '../shared/module'; import { operationToZodSchema } from '../shared/operation'; @@ -23,8 +24,12 @@ const arrayTypeToZodSchema = ({ schema: SchemaWithType<'array'>; state: State; }): ts.CallExpression => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const functionName = tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.array, }); @@ -35,6 +40,7 @@ const arrayTypeToZodSchema = ({ functionName, parameters: [ unknownTypeToZodSchema({ + plugin, schema: { type: 'unknown', }, @@ -69,13 +75,13 @@ const arrayTypeToZodSchema = ({ arrayExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.array, }), parameters: [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.union, }), parameters: [ @@ -123,14 +129,20 @@ const arrayTypeToZodSchema = ({ }; const booleanTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'boolean'>; }) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (typeof schema.const === 'boolean') { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.boolean(schema.const)], @@ -140,7 +152,7 @@ const booleanTypeToZodSchema = ({ const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.boolean, }), }); @@ -148,10 +160,16 @@ const booleanTypeToZodSchema = ({ }; const enumTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'enum'>; }): ts.CallExpression => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const enumMembers: Array = []; let isNullable = false; @@ -171,6 +189,7 @@ const enumTypeToZodSchema = ({ if (!enumMembers.length) { return unknownTypeToZodSchema({ + plugin, schema: { type: 'unknown', }, @@ -179,7 +198,7 @@ const enumTypeToZodSchema = ({ let enumExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.enum, }), parameters: [ @@ -202,22 +221,36 @@ const enumTypeToZodSchema = ({ return enumExpression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const neverTypeToZodSchema = (_props: { schema: SchemaWithType<'never'> }) => { +const neverTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; + schema: SchemaWithType<'never'>; +}) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.never, }), }); return expression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const nullTypeToZodSchema = (_props: { schema: SchemaWithType<'null'> }) => { +const nullTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; + schema: SchemaWithType<'null'>; +}) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.null, }), }); @@ -250,17 +283,23 @@ const numberParameter = ({ }; const numberTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'integer' | 'number'>; }) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const isBigInt = schema.type === 'integer' && schema.format === 'int64'; if (typeof schema.const === 'number') { // TODO: parser - handle bigint constants const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.number(schema.const)], @@ -272,13 +311,13 @@ const numberTypeToZodSchema = ({ functionName: isBigInt ? tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.coerce, }), name: identifiers.bigint, }) : tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.number, }), }); @@ -347,6 +386,10 @@ const objectTypeToZodSchema = ({ anyType: string; expression: ts.CallExpression; } => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + // TODO: parser - handle constants const properties: Array = []; @@ -401,7 +444,7 @@ const objectTypeToZodSchema = ({ }).expression; const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.record, }), parameters: [zodSchema], @@ -414,7 +457,7 @@ const objectTypeToZodSchema = ({ const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.object, }), parameters: [ts.factory.createObjectLiteralExpression(properties, true)], @@ -432,10 +475,14 @@ const stringTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'string'>; }) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (typeof schema.const === 'string') { const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.string(schema.const)], @@ -445,7 +492,7 @@ const stringTypeToZodSchema = ({ let stringExpression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.string, }), }); @@ -581,11 +628,15 @@ const tupleTypeToZodSchema = ({ schema: SchemaWithType<'tuple'>; state: State; }) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (schema.const && Array.isArray(schema.const)) { const tupleElements = schema.const.map((value) => tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.valueToExpression({ value })], @@ -593,7 +644,7 @@ const tupleTypeToZodSchema = ({ ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.tuple, }), parameters: [ @@ -619,7 +670,7 @@ const tupleTypeToZodSchema = ({ const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.tuple, }), parameters: [ @@ -631,37 +682,54 @@ const tupleTypeToZodSchema = ({ return expression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const undefinedTypeToZodSchema = (_props: { +const undefinedTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'undefined'>; }) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.undefined, }), }); return expression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const unknownTypeToZodSchema = (_props: { +const unknownTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'unknown'>; }) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.unknown, }), }); return expression; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const voidTypeToZodSchema = (_props: { schema: SchemaWithType<'void'> }) => { +const voidTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; + schema: SchemaWithType<'void'>; +}) => { + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.void, }), }); @@ -692,12 +760,14 @@ const schemaTypeToZodSchema = ({ case 'boolean': return { expression: booleanTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'boolean'>, }), }; case 'enum': return { expression: enumTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'enum'>, }), }; @@ -705,18 +775,21 @@ const schemaTypeToZodSchema = ({ case 'number': return { expression: numberTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'integer' | 'number'>, }), }; case 'never': return { expression: neverTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'never'>, }), }; case 'null': return { expression: nullTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'null'>, }), }; @@ -744,18 +817,21 @@ const schemaTypeToZodSchema = ({ case 'undefined': return { expression: undefinedTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'undefined'>, }), }; case 'unknown': return { expression: unknownTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'unknown'>, }), }; case 'void': return { expression: voidTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'void'>, }), }; @@ -778,10 +854,14 @@ const schemaToZodSchema = ({ schema: IR.SchemaObject; state: State; }): ZodSchema => { - const file = plugin.context.file({ id: zodId })!; + const f = plugin.gen.ensureFile(plugin.output); let zodSchema: Partial = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (schema.$ref) { const isCircularReference = state.circularReferenceTracker.includes( schema.$ref, @@ -789,25 +869,31 @@ const schemaToZodSchema = ({ state.circularReferenceTracker.push(schema.$ref); state.currentReferenceTracker.push(schema.$ref); - const id = plugin.api.getId({ type: 'ref', value: schema.$ref }); + const selector = plugin.api.getSelector('ref', schema.$ref); + let symbol = plugin.gen.selectSymbolFirst(selector); if (isCircularReference) { - const expression = file.addNodeReference(id, { - factory: (text) => tsc.identifier({ text }), - }); + if (!symbol) { + symbol = f.ensureSymbol({ selector }); + } + zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.lazy, }), parameters: [ tsc.arrowFunction({ - statements: [tsc.returnStatement({ expression })], + statements: [ + tsc.returnStatement({ + expression: tsc.identifier({ text: symbol.placeholder }), + }), + ], }), ], }); state.hasCircularReference = true; - } else if (!file.getName(id)) { + } else if (!symbol) { // if $ref hasn't been processed yet, inline it to avoid the // "Block-scoped variable used before its declaration." error // this could be (maybe?) fixed by reshuffling the generation order @@ -821,10 +907,8 @@ const schemaToZodSchema = ({ } if (!isCircularReference) { - const expression = file.addNodeReference(id, { - factory: (text) => tsc.identifier({ text }), - }); - zodSchema.expression = expression; + const symbol = plugin.gen.selectSymbolFirstOrThrow(selector); + zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); } state.circularReferenceTracker.pop(); @@ -867,7 +951,7 @@ const schemaToZodSchema = ({ ) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.intersection, }), parameters: itemTypes, @@ -887,7 +971,7 @@ const schemaToZodSchema = ({ } else { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.union, }), parameters: [ @@ -980,51 +1064,55 @@ const handleComponent = ({ }; } - const file = plugin.context.file({ id: zodId })!; - const schemaId = plugin.api.getId({ type: 'ref', value: id }); - - if (file.getName(schemaId)) return; + const selector = plugin.api.getSelector('ref', id); + let symbol = plugin.gen.selectSymbolFirst(selector); + if (symbol && !symbol.headless) return; const zodSchema = schemaToZodSchema({ plugin, schema, state }); - const typeInferId = plugin.config.definitions.types.infer.enabled - ? plugin.api.getId({ type: 'type-infer-ref', value: id }) + const f = plugin.gen.ensureFile(plugin.output); + const baseName = refToName(id); + symbol = f.ensureSymbol({ selector }); + symbol = symbol.update({ + name: buildName({ + config: plugin.config.definitions, + name: baseName, + }), + }); + const typeInferSymbol = plugin.config.definitions.types.infer.enabled + ? f.addSymbol({ + name: buildName({ + config: plugin.config.definitions.types.infer, + name: baseName, + }), + selector: plugin.api.getSelector('type-infer-ref', id), + }) : undefined; exportZodSchema({ plugin, schema, - schemaId, - typeInferId, + symbol, + typeInferSymbol, zodSchema, }); - const baseName = refToName(id); - file.updateNodeReferences( - schemaId, - buildName({ - config: plugin.config.definitions, - name: baseName, - }), - ); - if (typeInferId) { - file.updateNodeReferences( - typeInferId, - buildName({ - config: plugin.config.definitions.types.infer, - name: baseName, - }), - ); - } }; export const handlerV3: ZodPlugin['Handler'] = ({ plugin }) => { - const file = plugin.createFile({ - case: plugin.config.case, - id: zodId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); - file.import({ - module: getZodModule({ plugin }), - name: identifiers.z.text, + const zSymbol = f.ensureSymbol({ + name: 'z', + selector: plugin.api.getSelector('import', 'zod'), + }); + f.addImport({ + aliases: { + z: zSymbol.placeholder, + }, + from: getZodModule({ plugin }), + names: ['z'], }); plugin.forEach( @@ -1034,51 +1122,62 @@ export const handlerV3: ZodPlugin['Handler'] = ({ plugin }) => { 'schema', 'webhook', (event) => { - if (event.type === 'operation') { - operationToZodSchema({ - getZodSchema: (schema) => { - const state: State = { - circularReferenceTracker: [], - currentReferenceTracker: [], - hasCircularReference: false, - }; - return schemaToZodSchema({ plugin, schema, state }); - }, - operation: event.operation, - plugin, - }); - } else if (event.type === 'parameter') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.parameter.schema, - }); - } else if (event.type === 'requestBody') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.requestBody.schema, - }); - } else if (event.type === 'schema') { - handleComponent({ - id: event.$ref, - plugin, - schema: event.schema, - }); - } else if (event.type === 'webhook') { - webhookToZodSchema({ - getZodSchema: (schema) => { - const state: State = { - circularReferenceTracker: [], - currentReferenceTracker: [], - hasCircularReference: false, - }; - return schemaToZodSchema({ plugin, schema, state }); - }, - operation: event.operation, - plugin, - }); + switch (event.type) { + case 'operation': + operationToZodSchema({ + getZodSchema: (schema) => { + const state: State = { + circularReferenceTracker: [], + currentReferenceTracker: [], + hasCircularReference: false, + }; + return schemaToZodSchema({ plugin, schema, state }); + }, + operation: event.operation, + plugin, + }); + break; + case 'parameter': + handleComponent({ + id: event.$ref, + plugin, + schema: event.parameter.schema, + }); + break; + case 'requestBody': + handleComponent({ + id: event.$ref, + plugin, + schema: event.requestBody.schema, + }); + break; + case 'schema': + handleComponent({ + id: event.$ref, + plugin, + schema: event.schema, + }); + break; + case 'webhook': + webhookToZodSchema({ + getZodSchema: (schema) => { + const state: State = { + circularReferenceTracker: [], + currentReferenceTracker: [], + hasCircularReference: false, + }; + return schemaToZodSchema({ plugin, schema, state }); + }, + operation: event.operation, + plugin, + }); + break; } }, ); + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/packages/openapi-ts/src/plugins/zod/v4/plugin.ts b/packages/openapi-ts/src/plugins/zod/v4/plugin.ts index f113ad1af..67c1c4bc0 100644 --- a/packages/openapi-ts/src/plugins/zod/v4/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/v4/plugin.ts @@ -1,13 +1,13 @@ import ts from 'typescript'; -// import { TypeScriptRenderer } from '../../../generate/renderer'; +import { TypeScriptRenderer } from '../../../generate/renderer'; import { deduplicateSchema } from '../../../ir/schema'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { refToName } from '../../../utils/ref'; import { numberRegExp } from '../../../utils/regexp'; -import { identifiers, zodId } from '../constants'; +import { identifiers } from '../constants'; import { exportZodSchema } from '../export'; import { getZodModule } from '../shared/module'; import { operationToZodSchema } from '../shared/operation'; @@ -26,8 +26,12 @@ const arrayTypeToZodSchema = ({ }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + const functionName = tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.array, }); @@ -36,6 +40,7 @@ const arrayTypeToZodSchema = ({ functionName, parameters: [ unknownTypeToZodSchema({ + plugin, schema: { type: 'unknown', }, @@ -73,13 +78,13 @@ const arrayTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.array, }), parameters: [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.union, }), parameters: [ @@ -127,16 +132,22 @@ const arrayTypeToZodSchema = ({ }; const booleanTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'boolean'>; }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (typeof schema.const === 'boolean') { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.boolean(schema.const)], @@ -146,7 +157,7 @@ const booleanTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.boolean, }), }); @@ -154,8 +165,10 @@ const booleanTypeToZodSchema = ({ }; const enumTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'enum'>; }): Omit => { const result: Partial> = {}; @@ -179,15 +192,20 @@ const enumTypeToZodSchema = ({ if (!enumMembers.length) { return unknownTypeToZodSchema({ + plugin, schema: { type: 'unknown', }, }); } + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.enum, }), parameters: [ @@ -201,7 +219,7 @@ const enumTypeToZodSchema = ({ if (isNullable) { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.nullable, }), parameters: [result.expression], @@ -211,28 +229,38 @@ const enumTypeToZodSchema = ({ return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const neverTypeToZodSchema = (_props: { +const neverTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'never'>; }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.never, }), }); return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const nullTypeToZodSchema = (_props: { +const nullTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'null'>; }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.null, }), }); @@ -265,19 +293,25 @@ const numberParameter = ({ }; const numberTypeToZodSchema = ({ + plugin, schema, }: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'integer' | 'number'>; }): Omit => { const result: Partial> = {}; const isBigInt = schema.type === 'integer' && schema.format === 'int64'; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (typeof schema.const === 'number') { // TODO: parser - handle bigint constants result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.number(schema.const)], @@ -289,13 +323,13 @@ const numberTypeToZodSchema = ({ functionName: isBigInt ? tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.coerce, }), name: identifiers.bigint, }) : tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.number, }), }); @@ -303,7 +337,7 @@ const numberTypeToZodSchema = ({ if (!isBigInt && schema.type === 'integer') { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.int, }), }); @@ -369,6 +403,10 @@ const objectTypeToZodSchema = ({ const required = schema.required ?? []; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + for (const name in schema.properties) { const property = schema.properties[name]!; const isRequired = required.includes(name); @@ -410,7 +448,7 @@ const objectTypeToZodSchema = ({ // @ts-expect-error returnType: propertySchema.typeName ? tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: propertySchema.typeName, }) : undefined, @@ -442,13 +480,13 @@ const objectTypeToZodSchema = ({ }); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.record, }), parameters: [ tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.string, }), parameters: [], @@ -473,7 +511,7 @@ const objectTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.object, }), parameters: [ts.factory.createObjectLiteralExpression(properties, true)], @@ -499,10 +537,14 @@ const stringTypeToZodSchema = ({ }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (typeof schema.const === 'string') { result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.ots.string(schema.const)], @@ -512,7 +554,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.string, }), }); @@ -532,7 +574,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.iso, }), name: identifiers.date, @@ -543,7 +585,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.iso, }), name: identifiers.datetime, @@ -561,7 +603,7 @@ const stringTypeToZodSchema = ({ case 'email': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.email, }), }); @@ -569,7 +611,7 @@ const stringTypeToZodSchema = ({ case 'ipv4': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.ipv4, }), }); @@ -577,7 +619,7 @@ const stringTypeToZodSchema = ({ case 'ipv6': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.ipv6, }), }); @@ -586,7 +628,7 @@ const stringTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.iso, }), name: identifiers.time, @@ -596,7 +638,7 @@ const stringTypeToZodSchema = ({ case 'uri': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.url, }), }); @@ -604,7 +646,7 @@ const stringTypeToZodSchema = ({ case 'uuid': result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.uuid, }), }); @@ -666,11 +708,15 @@ const tupleTypeToZodSchema = ({ }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (schema.const && Array.isArray(schema.const)) { const tupleElements = schema.const.map((value) => tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.literal, }), parameters: [tsc.valueToExpression({ value })], @@ -678,7 +724,7 @@ const tupleTypeToZodSchema = ({ ); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.tuple, }), parameters: [ @@ -707,7 +753,7 @@ const tupleTypeToZodSchema = ({ result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.tuple, }), parameters: [ @@ -720,42 +766,57 @@ const tupleTypeToZodSchema = ({ return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const undefinedTypeToZodSchema = (_props: { +const undefinedTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'undefined'>; }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.undefined, }), }); return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const unknownTypeToZodSchema = (_props: { +const unknownTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'unknown'>; }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.unknown, }), }); return result as Omit; }; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const voidTypeToZodSchema = (_props: { +const voidTypeToZodSchema = ({ + plugin, +}: { + plugin: ZodPlugin['Instance']; schema: SchemaWithType<'void'>; }): Omit => { const result: Partial> = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); result.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.void, }), }); @@ -780,23 +841,28 @@ const schemaTypeToZodSchema = ({ }); case 'boolean': return booleanTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'boolean'>, }); case 'enum': return enumTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'enum'>, }); case 'integer': case 'number': return numberTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'integer' | 'number'>, }); case 'never': return neverTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'never'>, }); case 'null': return nullTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'null'>, }); case 'object': @@ -818,14 +884,17 @@ const schemaTypeToZodSchema = ({ }); case 'undefined': return undefinedTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'undefined'>, }); case 'unknown': return unknownTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'unknown'>, }); case 'void': return voidTypeToZodSchema({ + plugin, schema: schema as SchemaWithType<'void'>, }); } @@ -847,10 +916,14 @@ const schemaToZodSchema = ({ schema: IR.SchemaObject; state: State; }): ZodSchema => { - const file = plugin.context.file({ id: zodId })!; + const f = plugin.gen.ensureFile(plugin.output); let zodSchema: Partial = {}; + const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + plugin.api.getSelector('import', 'zod'), + ); + if (schema.$ref) { const isCircularReference = state.circularReferenceTracker.includes( schema.$ref, @@ -859,30 +932,36 @@ const schemaToZodSchema = ({ state.circularReferenceTracker.push(schema.$ref); state.currentReferenceTracker.push(schema.$ref); - const id = plugin.api.getId({ type: 'ref', value: schema.$ref }); + const selector = plugin.api.getSelector('ref', schema.$ref); + let symbol = plugin.gen.selectSymbolFirst(selector); if (isCircularReference) { - const expression = file.addNodeReference(id, { - factory: (text) => tsc.identifier({ text }), - }); + if (!symbol) { + symbol = f.ensureSymbol({ selector }); + } + if (isSelfReference) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.lazy, }), parameters: [ tsc.arrowFunction({ returnType: tsc.keywordTypeNode({ keyword: 'any' }), - statements: [tsc.returnStatement({ expression })], + statements: [ + tsc.returnStatement({ + expression: tsc.identifier({ text: symbol.placeholder }), + }), + ], }), ], }); } else { - zodSchema.expression = expression; + zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); } zodSchema.hasCircularReference = true; - } else if (!file.getName(id)) { + } else if (!symbol) { // if $ref hasn't been processed yet, inline it to avoid the // "Block-scoped variable used before its declaration." error // this could be (maybe?) fixed by reshuffling the generation order @@ -896,10 +975,8 @@ const schemaToZodSchema = ({ } if (!isCircularReference) { - const expression = file.addNodeReference(id, { - factory: (text) => tsc.identifier({ text }), - }); - zodSchema.expression = expression; + const symbol = plugin.gen.selectSymbolFirstOrThrow(selector); + zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); } state.circularReferenceTracker.pop(); @@ -917,7 +994,7 @@ const schemaToZodSchema = ({ }), parameters: [ tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.globalRegistry, }), tsc.objectExpression({ @@ -955,7 +1032,7 @@ const schemaToZodSchema = ({ ) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.intersection, }), parameters: itemTypes, @@ -975,7 +1052,7 @@ const schemaToZodSchema = ({ } else { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.union, }), parameters: [ @@ -1013,7 +1090,7 @@ const schemaToZodSchema = ({ if (optional) { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ - expression: identifiers.z, + expression: zSymbol.placeholder, name: identifiers.optional, }), parameters: [zodSchema.expression], @@ -1060,58 +1137,56 @@ const handleComponent = ({ currentReferenceTracker: [id], }; - const file = plugin.context.file({ id: zodId })!; - const schemaId = plugin.api.getId({ type: 'ref', value: id }); - - if (file.getName(schemaId)) return; + const selector = plugin.api.getSelector('ref', id); + let symbol = plugin.gen.selectSymbolFirst(selector); + if (symbol && !symbol.headless) return; const zodSchema = schemaToZodSchema({ plugin, schema, state }); - const typeInferId = plugin.config.definitions.types.infer.enabled - ? plugin.api.getId({ type: 'type-infer-ref', value: id }) + const f = plugin.gen.ensureFile(plugin.output); + const baseName = refToName(id); + symbol = f.ensureSymbol({ selector }); + symbol = symbol.update({ + name: buildName({ + config: plugin.config.definitions, + name: baseName, + }), + }); + const typeInferSymbol = plugin.config.definitions.types.infer.enabled + ? f.addSymbol({ + name: buildName({ + config: plugin.config.definitions.types.infer, + name: baseName, + }), + selector: plugin.api.getSelector('type-infer-ref', id), + }) : undefined; exportZodSchema({ plugin, schema, - schemaId, - typeInferId, + symbol, + typeInferSymbol, zodSchema, }); - const baseName = refToName(id); - file.updateNodeReferences( - schemaId, - buildName({ - config: plugin.config.definitions, - name: baseName, - }), - ); - if (typeInferId) { - file.updateNodeReferences( - typeInferId, - buildName({ - config: plugin.config.definitions.types.infer, - name: baseName, - }), - ); - } }; export const handlerV4: ZodPlugin['Handler'] = ({ plugin }) => { - const file = plugin.createFile({ - case: plugin.config.case, - id: zodId, - path: plugin.output, + const f = plugin.gen.createFile(plugin.output, { + extension: '.ts', + path: '{{path}}.gen', + renderer: new TypeScriptRenderer(), }); - // const f = plugin.gen.createFile(plugin.output, { - // extension: '.ts', - // path: '{{path}}.gen', - // renderer: new TypeScriptRenderer(), - // }); - - file.import({ - module: getZodModule({ plugin }), - name: identifiers.z.text, + + const zSymbol = f.ensureSymbol({ + name: 'z', + selector: plugin.api.getSelector('import', 'zod'), + }); + f.addImport({ + aliases: { + z: zSymbol.placeholder, + }, + from: getZodModule({ plugin }), + names: ['z'], }); - // f.addImport({ from: getZodModule({ plugin }), names: [identifiers.z.text] }); plugin.forEach( 'operation', @@ -1174,8 +1249,8 @@ export const handlerV4: ZodPlugin['Handler'] = ({ plugin }) => { }, ); - // if (plugin.config.exportFromIndex && f.hasContent()) { - // const index = plugin.gen.ensureFile('index'); - // index.addExport({ from: f, namespaceImport: true }); - // } + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c439e493b..ffc9980f2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1127,6 +1127,9 @@ importers: '@config/vite-base': specifier: workspace:* version: link:../config-vite-base + '@hey-api/codegen-core': + specifier: workspace:* + version: link:../codegen-core '@hey-api/openapi-ts': specifier: workspace:* version: link:../openapi-ts @@ -1324,6 +1327,9 @@ importers: '@config/vite-base': specifier: workspace:* version: link:../../config-vite-base + '@hey-api/codegen-core': + specifier: workspace:* + version: link:../../codegen-core '@hey-api/custom-client': specifier: workspace:* version: link:../../custom-client From 8654b2a78b8beb988a04de45ce622da18578d7f2 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 02:10:58 +0800 Subject: [PATCH 2/5] test: add snapshots --- package.json | 2 +- .../__snapshots__/2.0.x/external/types.gen.ts | 176 +- .../@angular/common/http/requests.gen.ts | 438 ++++ .../@angular/common/http/resources.gen.ts | 362 +++ .../common/default-class/client.gen.ts | 32 + .../common/default-class/client/client.gen.ts | 261 +++ .../common/default-class/client/index.ts | 25 + .../common/default-class/client/types.gen.ts | 283 +++ .../common/default-class/client/utils.gen.ts | 431 ++++ .../common/default-class/core/auth.gen.ts | 42 + .../default-class/core/bodySerializer.gen.ts | 92 + .../common/default-class/core/params.gen.ts | 153 ++ .../default-class/core/pathSerializer.gen.ts | 181 ++ .../core/serverSentEvents.gen.ts | 264 +++ .../common/default-class/core/types.gen.ts | 118 + .../common/default-class/core/utils.gen.ts | 143 ++ .../@angular/common/default-class/index.ts | 4 + .../@angular/common/default-class/sdk.gen.ts | 277 +++ .../common/default-class/types.gen.ts | 1178 ++++++++++ .../@angular/common/http/requests.gen.ts | 316 +++ .../@angular/common/http/resources.gen.ts | 248 ++ .../@angular/common/default/client.gen.ts | 32 + .../common/default/client/client.gen.ts | 261 +++ .../@angular/common/default/client/index.ts | 25 + .../common/default/client/types.gen.ts | 283 +++ .../common/default/client/utils.gen.ts | 431 ++++ .../@angular/common/default/core/auth.gen.ts | 42 + .../common/default/core/bodySerializer.gen.ts | 92 + .../common/default/core/params.gen.ts | 153 ++ .../common/default/core/pathSerializer.gen.ts | 181 ++ .../default/core/serverSentEvents.gen.ts | 264 +++ .../@angular/common/default/core/types.gen.ts | 118 + .../@angular/common/default/core/utils.gen.ts | 143 ++ .../plugins/@angular/common/default/index.ts | 4 + .../@angular/common/default/sdk.gen.ts | 277 +++ .../@angular/common/default/types.gen.ts | 1178 ++++++++++ .../@hey-api/schemas/default/schemas.gen.ts | 26 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 15 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 15 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 15 +- .../axios/types.gen.ts | 15 +- .../fetch/types.gen.ts | 15 +- .../@tanstack/react-query/axios/types.gen.ts | 15 +- .../@tanstack/react-query/fetch/types.gen.ts | 15 +- .../@tanstack/solid-query/axios/types.gen.ts | 15 +- .../@tanstack/solid-query/fetch/types.gen.ts | 15 +- .../@tanstack/svelte-query/axios/types.gen.ts | 15 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 15 +- .../@tanstack/vue-query/axios/types.gen.ts | 15 +- .../@tanstack/vue-query/fetch/types.gen.ts | 15 +- .../plugins/fastify/default/types.gen.ts | 15 +- .../plugins/valibot/default/valibot.gen.ts | 9 +- .../__snapshots__/3.0.x/external/types.gen.ts | 178 +- .../@angular/common/http/requests.gen.ts | 607 +++++ .../@angular/common/http/resources.gen.ts | 503 ++++ .../common/default-class/client.gen.ts | 32 + .../common/default-class/client/client.gen.ts | 261 +++ .../common/default-class/client/index.ts | 25 + .../common/default-class/client/types.gen.ts | 283 +++ .../common/default-class/client/utils.gen.ts | 431 ++++ .../common/default-class/core/auth.gen.ts | 42 + .../default-class/core/bodySerializer.gen.ts | 92 + .../common/default-class/core/params.gen.ts | 153 ++ .../default-class/core/pathSerializer.gen.ts | 181 ++ .../core/serverSentEvents.gen.ts | 264 +++ .../common/default-class/core/types.gen.ts | 118 + .../common/default-class/core/utils.gen.ts | 143 ++ .../@angular/common/default-class/index.ts | 4 + .../@angular/common/default-class/sdk.gen.ts | 409 ++++ .../common/default-class/types.gen.ts | 2046 ++++++++++++++++ .../@angular/common/http/requests.gen.ts | 444 ++++ .../@angular/common/http/resources.gen.ts | 348 +++ .../@angular/common/default/client.gen.ts | 32 + .../common/default/client/client.gen.ts | 261 +++ .../@angular/common/default/client/index.ts | 25 + .../common/default/client/types.gen.ts | 283 +++ .../common/default/client/utils.gen.ts | 431 ++++ .../@angular/common/default/core/auth.gen.ts | 42 + .../common/default/core/bodySerializer.gen.ts | 92 + .../common/default/core/params.gen.ts | 153 ++ .../common/default/core/pathSerializer.gen.ts | 181 ++ .../default/core/serverSentEvents.gen.ts | 264 +++ .../@angular/common/default/core/types.gen.ts | 118 + .../@angular/common/default/core/utils.gen.ts | 143 ++ .../plugins/@angular/common/default/index.ts | 4 + .../@angular/common/default/sdk.gen.ts | 409 ++++ .../@angular/common/default/types.gen.ts | 2046 ++++++++++++++++ .../@hey-api/schemas/default/schemas.gen.ts | 26 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 15 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 15 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 15 +- .../axios/types.gen.ts | 15 +- .../fetch/types.gen.ts | 15 +- .../@tanstack/react-query/axios/types.gen.ts | 15 +- .../@tanstack/react-query/fetch/types.gen.ts | 15 +- .../@tanstack/solid-query/axios/types.gen.ts | 15 +- .../@tanstack/solid-query/fetch/types.gen.ts | 15 +- .../@tanstack/svelte-query/axios/types.gen.ts | 15 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 15 +- .../@tanstack/vue-query/axios/types.gen.ts | 15 +- .../@tanstack/vue-query/fetch/types.gen.ts | 15 +- .../plugins/fastify/default/types.gen.ts | 15 +- .../plugins/valibot/default/valibot.gen.ts | 9 +- .../client-axios/base-url-false/types.gen.ts | 12 +- .../client-axios/base-url-number/types.gen.ts | 12 +- .../client-axios/base-url-strict/types.gen.ts | 12 +- .../client-axios/base-url-string/types.gen.ts | 12 +- .../client-axios/clean-false/types.gen.ts | 12 +- .../client-axios/default/types.gen.ts | 12 +- .../sdk-client-optional/types.gen.ts | 12 +- .../sdk-client-required/types.gen.ts | 12 +- .../tsconfig-nodenext-sdk/types.gen.ts | 12 +- .../client-fetch/base-url-false/types.gen.ts | 12 +- .../client-fetch/base-url-number/types.gen.ts | 12 +- .../client-fetch/base-url-strict/types.gen.ts | 12 +- .../client-fetch/base-url-string/types.gen.ts | 12 +- .../client-fetch/clean-false/types.gen.ts | 12 +- .../client-fetch/default/types.gen.ts | 12 +- .../sdk-client-optional/types.gen.ts | 12 +- .../sdk-client-required/types.gen.ts | 12 +- .../tsconfig-nodenext-sdk/types.gen.ts | 12 +- .../client-next/base-url-false/types.gen.ts | 12 +- .../client-next/base-url-number/types.gen.ts | 12 +- .../client-next/base-url-strict/types.gen.ts | 12 +- .../client-next/base-url-string/types.gen.ts | 12 +- .../client-next/clean-false/types.gen.ts | 12 +- .../@hey-api/client-next/default/types.gen.ts | 12 +- .../sdk-client-optional/types.gen.ts | 12 +- .../sdk-client-required/types.gen.ts | 12 +- .../tsconfig-nodenext-sdk/types.gen.ts | 12 +- .../client-nuxt/base-url-false/types.gen.ts | 12 +- .../client-nuxt/base-url-number/types.gen.ts | 12 +- .../client-nuxt/base-url-strict/types.gen.ts | 12 +- .../client-nuxt/base-url-string/types.gen.ts | 12 +- .../client-nuxt/clean-false/types.gen.ts | 12 +- .../@hey-api/client-nuxt/default/types.gen.ts | 12 +- .../sdk-client-optional/types.gen.ts | 12 +- .../sdk-client-required/types.gen.ts | 12 +- .../tsconfig-nodenext-sdk/types.gen.ts | 12 +- .../client-custom/base-url-false/types.gen.ts | 12 +- .../base-url-number/types.gen.ts | 12 +- .../base-url-strict/types.gen.ts | 12 +- .../base-url-string/types.gen.ts | 12 +- .../clients/client-custom/bundle/types.gen.ts | 12 +- .../client-custom/default/types.gen.ts | 12 +- .../sdk-client-optional/types.gen.ts | 12 +- .../sdk-client-required/types.gen.ts | 12 +- .../my-client/base-url-false/types.gen.ts | 12 +- .../my-client/base-url-number/types.gen.ts | 12 +- .../my-client/base-url-strict/types.gen.ts | 12 +- .../my-client/base-url-string/types.gen.ts | 12 +- .../clients/my-client/bundle/types.gen.ts | 12 +- .../clients/my-client/default/types.gen.ts | 12 +- .../sdk-client-optional/types.gen.ts | 12 +- .../sdk-client-required/types.gen.ts | 12 +- .../__snapshots__/3.1.x/external/types.gen.ts | 178 +- .../@angular/common/http/requests.gen.ts | 607 +++++ .../@angular/common/http/resources.gen.ts | 503 ++++ .../common/default-class/client.gen.ts | 32 + .../common/default-class/client/client.gen.ts | 261 +++ .../common/default-class/client/index.ts | 25 + .../common/default-class/client/types.gen.ts | 283 +++ .../common/default-class/client/utils.gen.ts | 431 ++++ .../common/default-class/core/auth.gen.ts | 42 + .../default-class/core/bodySerializer.gen.ts | 92 + .../common/default-class/core/params.gen.ts | 153 ++ .../default-class/core/pathSerializer.gen.ts | 181 ++ .../core/serverSentEvents.gen.ts | 264 +++ .../common/default-class/core/types.gen.ts | 118 + .../common/default-class/core/utils.gen.ts | 143 ++ .../@angular/common/default-class/index.ts | 4 + .../@angular/common/default-class/sdk.gen.ts | 409 ++++ .../common/default-class/types.gen.ts | 2065 +++++++++++++++++ .../@angular/common/http/requests.gen.ts | 444 ++++ .../@angular/common/http/resources.gen.ts | 348 +++ .../@angular/common/default/client.gen.ts | 32 + .../common/default/client/client.gen.ts | 261 +++ .../@angular/common/default/client/index.ts | 25 + .../common/default/client/types.gen.ts | 283 +++ .../common/default/client/utils.gen.ts | 431 ++++ .../@angular/common/default/core/auth.gen.ts | 42 + .../common/default/core/bodySerializer.gen.ts | 92 + .../common/default/core/params.gen.ts | 153 ++ .../common/default/core/pathSerializer.gen.ts | 181 ++ .../default/core/serverSentEvents.gen.ts | 264 +++ .../@angular/common/default/core/types.gen.ts | 118 + .../@angular/common/default/core/utils.gen.ts | 143 ++ .../plugins/@angular/common/default/index.ts | 4 + .../@angular/common/default/sdk.gen.ts | 409 ++++ .../@angular/common/default/types.gen.ts | 2065 +++++++++++++++++ .../@hey-api/schemas/default/schemas.gen.ts | 26 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 12 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 12 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 12 +- .../axios/types.gen.ts | 12 +- .../fetch/types.gen.ts | 12 +- .../@tanstack/react-query/axios/types.gen.ts | 12 +- .../@tanstack/react-query/fetch/types.gen.ts | 12 +- .../@tanstack/solid-query/axios/types.gen.ts | 12 +- .../@tanstack/solid-query/fetch/types.gen.ts | 12 +- .../@tanstack/svelte-query/axios/types.gen.ts | 12 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 12 +- .../@tanstack/vue-query/axios/types.gen.ts | 12 +- .../@tanstack/vue-query/fetch/types.gen.ts | 12 +- .../plugins/fastify/default/types.gen.ts | 12 +- .../plugins/valibot/default/valibot.gen.ts | 12 +- .../main/test/plugins.test.ts | 24 + .../plugins/@angular/common/httpRequests.ts | 7 +- .../plugins/@angular/common/httpResources.ts | 7 +- 209 files changed, 31133 insertions(+), 869 deletions(-) create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/types.gen.ts diff --git a/package.json b/package.json index 7d6da7953..6cb3fc638 100644 --- a/package.json +++ b/package.json @@ -70,5 +70,5 @@ "typescript-eslint": "8.29.1", "vitest": "3.1.1" }, - "packageManager": "pnpm@10.15.0" + "packageManager": "pnpm@10.15.1" } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/types.gen.ts index 7e5716f45..3d1e1fbe6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/types.gen.ts @@ -1,127 +1,101 @@ // This file is auto-generated by @hey-api/openapi-ts -export type ExternalSchemaA = { - id: string; - name?: string; -}; +export type ExternalSchemaA = ExternalSharedExternalSharedModel; -export type ExternalSchemaB = { - id: string; - name?: string; -}; +export type ExternalSchemaB = ExternalSharedExternalSharedModel; -export type ExternalSchemaC = { - id: string; - name?: string; -}; +export type ExternalSchemaC = ExternalSharedExternalSharedModel; -export type ExternalSchemaPathA = { - id: string; - name?: string; -}; +export type ExternalSchemaPathA = ExternalSharedExternalSharedModel; -export type ExternalSchemaPathB = { - id: string; - name?: string; -}; +export type ExternalSchemaPathB = ExternalSharedExternalSharedModel; /** * External schema property (A) */ export type ExternalSchemaPropertyA = { - uuid1?: string; + uuid1?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property (B) - second use of UUID */ export type ExternalSchemaPropertyB = { - uuid2?: string; + uuid2?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property (C) - third use of UUID */ export type ExternalSchemaPropertyC = { - uuid3?: string; + uuid3?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property with duplicate refs (D) */ export type ExternalSchemaPropertyD = { - uuid4?: string; - uuid5?: _heyapi_10_; + uuid4?: ExternalSharedExternalSharedModelWithUuid; + uuid5?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property via external property ref (id) */ export type ExternalSchemaExternalProp = { - id3?: string; - id4?: 2; + id3?: ExternalSharedId; + id4?: ExternalSharedId; }; /** * Alias to external property via component property ref */ export type ExternalSchemaExternalPropAlias = { - id5?: string; - id6?: 2; + id5?: ExternalSharedId; + id6?: ExternalSharedId; }; /** * External double nested prop via property ref */ export type ExternalDoubleNestedProp = { - deep1?: string; - deep2?: 3; + deep1?: ExternalSharedDeep; + deep2?: ExternalSharedDeep; }; /** * External double nested numeric properties */ export type ExternalDoubleNestedNumeric = { - numeric1?: 4; - numeric2?: 4; + numeric1?: ExternalShared1; + numeric2?: ExternalShared1; }; -export type ExternalNestedObjectA = { - inner?: { - deep?: string; - }; -}; +export type ExternalNestedObjectA = ExternalSharedExternalNested; -export type ExternalNestedObjectB = { - inner?: { - deep?: string; - }; -}; +export type ExternalNestedObjectB = ExternalSharedExternalNested; -export type ExternalNestedNumericObjectA = 5; +export type ExternalNestedNumericObjectA = ExternalSharedExternalNestedNumeric; -export type ExternalNestedNumericObjectB = 5; +export type ExternalNestedNumericObjectB = ExternalSharedExternalNestedNumeric; /** * Mixed external property references */ export type ExternalMixedProperties = { - id7?: string; - name1?: string; - uuid6?: string; - deep3?: string; - numeric3?: 4; + id7?: ExternalSharedId; + name1?: ExternalSharedName; + uuid6?: ExternalSharedExternalSharedModelWithUuid; + deep3?: ExternalSharedDeep; + numeric3?: ExternalShared1; }; /** * Array containing external references */ export type ExternalArraySchema = { - items?: Array<{ - id: string; - name?: string; - }>; - uuidItems?: Array; + items?: Array; + uuidItems?: Array; }; /** @@ -132,11 +106,8 @@ export type ExternalUnionSchema = unknown; /** * AllOf with external references */ -export type ExternalAllOfSchema = { - id: string; - name?: string; -} & 6 & { - additional?: string; +export type ExternalAllOfSchema = ExternalSharedExternalSharedModel & { + additional?: ExternalSharedExternalSharedModelWithUuid; }; /** @@ -144,6 +115,33 @@ export type ExternalAllOfSchema = { */ export type ExternalAnyOfSchema = unknown; +export type ExternalSharedExternalNested = { + inner?: { + deep?: string; + }; +}; + +export type ExternalSharedDeep = string; + +export type ExternalSharedExternalNestedNumeric = { + 0?: { + 1?: string; + }; +}; + +export type ExternalShared1 = string; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +export type ExternalSharedId = string; + +export type ExternalSharedName = string; + +export type ExternalSharedExternalSharedModelWithUuid = string; + export type GetExternalModelData = { body?: never; path: { @@ -159,7 +157,7 @@ export type GetExternalModelErrors = { /** * Response using external UUID */ - 400: string; + 400: ExternalSharedExternalSharedModelWithUuid; }; export type GetExternalModelError = GetExternalModelErrors[keyof GetExternalModelErrors]; @@ -168,10 +166,7 @@ export type GetExternalModelResponses = { /** * Response using external model */ - 200: { - id: string; - name?: string; - }; + 200: ExternalSharedExternalSharedModel; }; export type GetExternalModelResponse = GetExternalModelResponses[keyof GetExternalModelResponses]; @@ -194,10 +189,7 @@ export type PostExternalModelResponses = { /** * Response using external model */ - 201: { - id: string; - name?: string; - }; + 201: ExternalSharedExternalSharedModel; }; export type PostExternalModelResponse = PostExternalModelResponses[keyof PostExternalModelResponses]; @@ -215,7 +207,7 @@ export type GetExternalUuidResponses = { /** * Response using external UUID */ - 200: string; + 200: ExternalSharedExternalSharedModelWithUuid; }; export type GetExternalUuidResponse = GetExternalUuidResponses[keyof GetExternalUuidResponses]; @@ -231,7 +223,7 @@ export type PutExternalUuidResponses = { /** * Response using external UUID */ - 200: string; + 200: ExternalSharedExternalSharedModelWithUuid; }; export type PutExternalUuidResponse = PutExternalUuidResponses[keyof PutExternalUuidResponses]; @@ -250,11 +242,7 @@ export type GetExternalNestedResponses = { /** * Response using external nested object */ - 200: { - inner?: { - deep?: string; - }; - }; + 200: ExternalSharedExternalNested; }; export type GetExternalNestedResponse = GetExternalNestedResponses[keyof GetExternalNestedResponses]; @@ -270,11 +258,7 @@ export type PostExternalNestedResponses = { /** * Response using external nested object */ - 201: { - inner?: { - deep?: string; - }; - }; + 201: ExternalSharedExternalNested; }; export type PostExternalNestedResponse = PostExternalNestedResponses[keyof PostExternalNestedResponses]; @@ -298,10 +282,7 @@ export type GetExternalMixedResponses = { /** * Response with array of external models */ - 200: Array<{ - id: string; - name?: string; - }>; + 200: Array; }; export type GetExternalMixedResponse = GetExternalMixedResponses[keyof GetExternalMixedResponses]; @@ -317,10 +298,7 @@ export type PostExternalMixedResponses = { /** * Response using external model */ - 201: { - id: string; - name?: string; - }; + 201: ExternalSharedExternalSharedModel; }; export type PostExternalMixedResponse = PostExternalMixedResponses[keyof PostExternalMixedResponses]; @@ -336,10 +314,7 @@ export type GetExternalArrayResponses = { /** * Response with array of external models */ - 200: Array<{ - id: string; - name?: string; - }>; + 200: Array; }; export type GetExternalArrayResponse = GetExternalArrayResponses[keyof GetExternalArrayResponses]; @@ -355,10 +330,7 @@ export type PostExternalArrayResponses = { /** * Response with array of external models */ - 201: Array<{ - id: string; - name?: string; - }>; + 201: Array; }; export type PostExternalArrayResponse = PostExternalArrayResponses[keyof PostExternalArrayResponses]; @@ -407,11 +379,11 @@ export type GetExternalPropertiesByIdData = { export type GetExternalPropertiesByIdResponses = { 200: { - id?: string; - name?: string; - uuid?: string; - deep?: string; - numeric?: 4; + id?: ExternalSharedId; + name?: ExternalSharedName; + uuid?: ExternalSharedExternalSharedModelWithUuid; + deep?: ExternalSharedDeep; + numeric?: ExternalShared1; }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts new file mode 100644 index 000000000..9a948d5c3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts @@ -0,0 +1,438 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpRequest } from '@angular/common/http'; +import type { Options } from '../../../sdk.gen'; +import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PostApiVbyApiVersionBodyData } from '../../../types.gen'; +import { client } from '../../../client.gen'; +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultRequests { + public serviceWithEmptyTag(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public patchApiVbyApiVersionNoTag(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public fooWow(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + /** + * Body should not be unknown + * Body should not be unknown + */ + public postApiVbyApiVersionBody(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/body', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleRequests { + public deleteCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public getCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public headCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'HEAD', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public optionsCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public patchCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public postCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public putCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/simple', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsRequests { + public callWithDescriptions(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/descriptions/', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersRequests { + public callWithParameters(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); + } + + public callWithWeirdParameterNames(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsRequests { + public callWithDefaultParameters(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/defaults', + ...options + }); + } + + public callWithDefaultOptionalParameters(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/defaults', + ...options + }); + } + + public callToTestOrderOfParams(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/defaults', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateRequests { + public duplicateName(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName2(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName3(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName4(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/duplicate', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentRequests { + public callWithNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no-content', + ...options + }); + } + + public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseRequests { + public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); + } + + public callWithResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/response', + ...options + }); + } + + public callWithDuplicateResponses(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/response', + ...options + }); + } + + public callWithResponses(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/response', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1Requests { + public dummyA(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); + } + + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2Requests { + public dummyA(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); + } + + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3Requests { + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatRequests { + public collectionFormat(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesRequests { + public types(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/types', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexRequests { + public complexTypes(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/complex', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderRequests { + public callWithResultFromHeader(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/header', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorRequests { + public testErrorCode(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/error', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊRequests { + public nonAsciiæøåÆøÅöôêÊ字符串(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts new file mode 100644 index 000000000..e5da517b1 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts @@ -0,0 +1,362 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options } from '../../../sdk.gen'; +import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyBData, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, ComplexTypesData, ComplexTypesResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse } from '../../../types.gen'; +import { httpResource } from '@angular/common/http'; +import { DefaultRequests, SimpleRequests, DescriptionsRequests, ParametersRequests, DefaultsRequests, DuplicateRequests, NoContentRequests, ResponseRequests, MultipleTags1Requests, CollectionFormatRequests, TypesRequests, ComplexRequests, HeaderRequests, ErrorRequests, NonAsciiÆøåÆøÅöôêÊRequests } from './requests.gen'; +import { inject, Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultResources { + public serviceWithEmptyTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).serviceWithEmptyTag(opts) : undefined; + }); + } + + public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + }); + } + + public fooWow(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).fooWow(opts) : undefined; + }); + } + + /** + * Body should not be unknown + * Body should not be unknown + */ + public postApiVbyApiVersionBody(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).postApiVbyApiVersionBody(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleResources { + public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).getCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).headCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).postCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).putCallWithoutParametersAndResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsResources { + public callWithDescriptions(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DescriptionsRequests).callWithDescriptions(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersResources { + public callWithParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).callWithParameters(opts) : undefined; + }); + } + + public callWithWeirdParameterNames(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).callWithWeirdParameterNames(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsResources { + public callWithDefaultParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callWithDefaultParameters(opts) : undefined; + }); + } + + public callWithDefaultOptionalParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callWithDefaultOptionalParameters(opts) : undefined; + }); + } + + public callToTestOrderOfParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callToTestOrderOfParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateResources { + public duplicateName(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName(opts) : undefined; + }); + } + + public duplicateName2(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName2(opts) : undefined; + }); + } + + public duplicateName3(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName3(opts) : undefined; + }); + } + + public duplicateName4(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName4(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentResources { + public callWithNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NoContentRequests).callWithNoContentResponse(opts) : undefined; + }); + } + + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseResources { + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } + + public callWithResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponse(opts) : undefined; + }); + } + + public callWithDuplicateResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithDuplicateResponses(opts) : undefined; + }); + } + + public callWithResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponses(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1Resources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2Resources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3Resources { + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatResources { + public collectionFormat(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(CollectionFormatRequests).collectionFormat(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesResources { + public types(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(TypesRequests).types(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexResources { + public complexTypes(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexRequests).complexTypes(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderResources { + public callWithResultFromHeader(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(HeaderRequests).callWithResultFromHeader(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorResources { + public testErrorCode(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ErrorRequests).testErrorCode(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊResources { + public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + }); + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts new file mode 100644 index 000000000..2e5fe1c9b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config2) => Config2 & T>; + +export const client = createClient2(createConfig2({ + baseUrl: 'http://localhost:3000/base' +})); + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig2 = (override?: Config) => Config & T>; + +export const client2 = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts new file mode 100644 index 000000000..40c2b65df --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -0,0 +1,261 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpResponse } from '@angular/common/http'; +import { + HttpClient, + HttpErrorResponse, + HttpEventType, + HttpRequest, +} from '@angular/common/http'; +import { + assertInInjectionContext, + inject, + provideAppInitializer, + runInInjectionContext, +} from '@angular/core'; +import { firstValueFrom } from 'rxjs'; +import { filter } from 'rxjs/operators'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, + ResponseStyle, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export function provideHeyApiClient(client: Client) { + return provideAppInitializer(() => { + const httpClient = inject(HttpClient); + client.setConfig({ httpClient }); + }); +} + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >(); + + const requestOptions = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + options: RequestOptions, + ) => { + const opts = { + ..._config, + ...options, + headers: mergeHeaders(_config.headers, options.headers), + httpClient: options.httpClient ?? _config.httpClient, + serializedBody: undefined, + }; + + if (!opts.httpClient) { + if (opts.injector) { + opts.httpClient = runInInjectionContext(opts.injector, () => + inject(HttpClient), + ); + } else { + assertInInjectionContext(requestOptions); + opts.httpClient = inject(HttpClient); + } + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts as any); + + const req = new HttpRequest( + opts.method ?? 'GET', + url, + getValidRequestBody(opts), + { + redirect: 'follow', + ...opts, + }, + ); + + return { opts, req, url }; + }; + + const beforeRequest = async (options: RequestOptions) => { + const { opts, req, url } = requestOptions(options); + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + return { opts, req, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, req: initialReq } = await beforeRequest(options); + + let req = initialReq; + + for (const fn of interceptors.request._fns) { + if (fn) { + req = await fn(req, opts as any); + } + } + + const result: { + request: HttpRequest; + response: any; + } = { + request: req, + response: null, + }; + + try { + result.response = (await firstValueFrom( + opts + .httpClient!.request(req) + .pipe(filter((event) => event.type === HttpEventType.Response)), + )) as HttpResponse; + + for (const fn of interceptors.response._fns) { + if (fn) { + result.response = await fn(result.response, req, opts as any); + } + } + + let bodyResponse = result.response.body; + + if (opts.responseValidator) { + await opts.responseValidator(bodyResponse); + } + + if (opts.responseTransformer) { + bodyResponse = await opts.responseTransformer(bodyResponse); + } + + return opts.responseStyle === 'data' + ? bodyResponse + : { data: bodyResponse, ...result }; + } catch (error) { + if (error instanceof HttpErrorResponse) { + result.response = error; + } + + let finalError = error instanceof HttpErrorResponse ? error.error : error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn( + finalError, + result.response as any, + req, + opts as any, + )) as string; + } + } + + if (opts.throwOnError) { + throw finalError; + } + + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + requestOptions: (options) => { + if (options.security) { + throw new Error('Security is not supported in requestOptions'); + } + + if (options.requestValidator) { + throw new Error( + 'Request validation is not supported in requestOptions', + ); + } + + return requestOptions(options).req; + }, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..6cdf8ad48 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/types.gen.ts @@ -0,0 +1,283 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + HttpClient, + HttpErrorResponse, + HttpHeaders, + HttpRequest, + HttpResponse, +} from '@angular/common/http'; +import type { Injector } from '@angular/core'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `HttpHeaders` object with. + * + * {@link https://angular.dev/api/common/http/HttpHeaders#constructor See more} + */ + headers?: + | HttpHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The HTTP client to use for making requests. + */ + httpClient?: HttpClient; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + /** + * Optional custom injector for dependency resolution if you don't implicitly or explicitly provide one. + */ + injector?: Injector; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = Promise< + ThrowOnError extends true + ? TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: HttpRequest; + response: HttpResponse; + } + : TResponseStyle extends 'data' + ? + | (TData extends Record ? TData[keyof TData] : TData) + | undefined + : + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + request: HttpRequest; + response: HttpResponse; + } + | { + data: undefined; + error: TError[keyof TError]; + request: HttpRequest; + response: HttpErrorResponse & { + error: TError[keyof TError] | null; + }; + } +>; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type RequestOptionsFn = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: RequestOptions, +) => HttpRequest; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >; + requestOptions: RequestOptionsFn; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts new file mode 100644 index 000000000..3bb799dff --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts @@ -0,0 +1,431 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { HttpHeaders } from '@angular/common/http'; + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +export const setAuthParams = async ( + options: Pick, 'security'> & + Pick & { + headers: HttpHeaders; + }, +) => { + for (const auth of options.security) { + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers = options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers = options.headers.set(name, token); + break; + } + + return; + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): HttpHeaders => { + let mergedHeaders = new HttpHeaders(); + + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + if (header instanceof HttpHeaders) { + // Merge HttpHeaders instance + header.keys().forEach((key) => { + const values = header.getAll(key); + if (values) { + values.forEach((value) => { + mergedHeaders = mergedHeaders.append(key, value); + }); + } + }); + } else { + // Merge plain object headers + for (const [key, value] of Object.entries(header)) { + if (value === null) { + mergedHeaders = mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders = mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders = mergedHeaders.set( + key, + typeof value === 'object' + ? JSON.stringify(value) + : (value as string), + ); + } + } + } + } + + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/sdk.gen.ts new file mode 100644 index 000000000..b215924fa --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/sdk.gen.ts @@ -0,0 +1,277 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const serviceWithEmptyTag = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/descriptions/', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); +}; + +export const callWithDefaultParameters = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + querySerializer: { + array: { + explode: false, + style: 'form' + } + }, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + querySerializer: { + array: { + explode: false, + style: 'form' + } + }, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Body should not be unknown + * Body should not be unknown + */ +export const postApiVbyApiVersionBody = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/body', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/types.gen.ts new file mode 100644 index 000000000..b0edf4e79 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/types.gen.ts @@ -0,0 +1,1178 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type ExternalRefA = ExternalSharedExternalSharedModel; + +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string; + bar?: string; +}>; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a type-only model that defines Date as a string + */ +export type _Date = string; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp: string | null; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + test?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string; + }; + }; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +export type Default = { + name?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type ParameterActivityParams = { + description?: string; + graduate_id?: number; + organization_id?: number; + parent_activity?: number; + post_id?: number; +}; + +export type ResponsePostActivityResponse = { + description?: string; + graduate_id?: number; + organization_id?: number; + parent_activity_id?: number; + post_id?: number; +}; + +export type FailureFailure = { + error?: string; + message?: string; + reference_code?: string; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type ServiceWithEmptyTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions/'; +}; + +export type CallWithParametersData = { + body?: never; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query: { + /** + * This is the parameter that goes into the query params + */ + parameterQuery: string; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + body?: never; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query: { + /** + * This is a simple string with default value + */ + parameterString: string; + /** + * This is a simple number with default value + */ + parameterNumber: number; + /** + * This is a simple boolean with default value + */ + parameterBoolean: boolean; + /** + * This is a simple enum with default value + */ + parameterEnum: 'Success' | 'Warning' | 'Error'; + /** + * This is a model with one string property + */ + parameterModel: { + /** + * This is a simple string property + */ + prop?: string; + }; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: unknown; +}; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: unknown; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + /** + * Success + */ + 204: unknown; +}; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: unknown; +}; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + /** + * Message for default response + */ + default: ModelWithString; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithString; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithString; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean; + /** + * This is an array parameter + */ + parameterArray: Array; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + }; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error'; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * This is a model with one string property + */ + parameterReference: { + /** + * This is a simple string property + */ + prop?: string; + }; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: string; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: NonAsciiStringæøåÆøÅöôêÊ字符串; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PostApiVbyApiVersionBodyData = { + /** + * Body should not be unknown + */ + body: ParameterActivityParams; + path?: never; + query?: never; + url: '/api/v{api-version}/body'; +}; + +export type PostApiVbyApiVersionBodyErrors = { + /** + * Bad Request + */ + 400: FailureFailure; + /** + * Internal Server Error + */ + 500: FailureFailure; +}; + +export type PostApiVbyApiVersionBodyError = PostApiVbyApiVersionBodyErrors[keyof PostApiVbyApiVersionBodyErrors]; + +export type PostApiVbyApiVersionBodyResponses = { + /** + * OK + */ + 200: ResponsePostActivityResponse; +}; + +export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses[keyof PostApiVbyApiVersionBodyResponses]; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts new file mode 100644 index 000000000..cdc646474 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts @@ -0,0 +1,316 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpRequest } from '@angular/common/http'; +import type { Options } from '../../../sdk.gen'; +import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PostApiVbyApiVersionBodyData } from '../../../types.gen'; +import { client } from '../../../client.gen'; + +export const serviceWithEmptyTagRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTagRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const fooWowRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'HEAD', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const callWithDescriptionsRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/descriptions/', + ...options + }); +}; + +export const callWithParametersRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); +}; + +export const callWithWeirdParameterNamesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); +}; + +export const callWithDefaultParametersRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParametersRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParamsRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateNameRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyARequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyBRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponsesRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponsesRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormatRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const typesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const complexTypesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const callWithResultFromHeaderRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCodeRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串Request = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Body should not be unknown + * Body should not be unknown + */ +export const postApiVbyApiVersionBodyRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/body', + ...options + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts new file mode 100644 index 000000000..df3ac474b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts @@ -0,0 +1,248 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options } from '../../../sdk.gen'; +import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyBData, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, ComplexTypesData, ComplexTypesResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse } from '../../../types.gen'; +import { httpResource } from '@angular/common/http'; +import { serviceWithEmptyTagRequest, patchApiVbyApiVersionNoTagRequest, fooWowRequest, deleteCallWithoutParametersAndResponseRequest, getCallWithoutParametersAndResponseRequest, headCallWithoutParametersAndResponseRequest, optionsCallWithoutParametersAndResponseRequest, patchCallWithoutParametersAndResponseRequest, postCallWithoutParametersAndResponseRequest, putCallWithoutParametersAndResponseRequest, callWithDescriptionsRequest, callWithParametersRequest, callWithWeirdParameterNamesRequest, callWithDefaultParametersRequest, callWithDefaultOptionalParametersRequest, callToTestOrderOfParamsRequest, duplicateNameRequest, duplicateName2Request, duplicateName3Request, duplicateName4Request, callWithNoContentResponseRequest, callWithResponseAndNoContentResponseRequest, dummyARequest, dummyBRequest, callWithResponseRequest, callWithDuplicateResponsesRequest, callWithResponsesRequest, collectionFormatRequest, typesRequest, complexTypesRequest, callWithResultFromHeaderRequest, testErrorCodeRequest, nonAsciiæøåÆøÅöôêÊ字符串Request, postApiVbyApiVersionBodyRequest } from './requests.gen'; + +export const serviceWithEmptyTagResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? serviceWithEmptyTagRequest(opts) : undefined; + }); +}; + +export const patchApiVbyApiVersionNoTagResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? patchApiVbyApiVersionNoTagRequest(opts) : undefined; + }); +}; + +export const fooWowResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? fooWowRequest(opts) : undefined; + }); +}; + +export const deleteCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? deleteCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const getCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? getCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const headCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? headCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const optionsCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? optionsCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const patchCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? patchCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const postCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const putCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? putCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const callWithDescriptionsResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDescriptionsRequest(opts) : undefined; + }); +}; + +export const callWithParametersResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithParametersRequest(opts) : undefined; + }); +}; + +export const callWithWeirdParameterNamesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithWeirdParameterNamesRequest(opts) : undefined; + }); +}; + +export const callWithDefaultParametersResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDefaultParametersRequest(opts) : undefined; + }); +}; + +export const callWithDefaultOptionalParametersResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDefaultOptionalParametersRequest(opts) : undefined; + }); +}; + +export const callToTestOrderOfParamsResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callToTestOrderOfParamsRequest(opts) : undefined; + }); +}; + +export const duplicateNameResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateNameRequest(opts) : undefined; + }); +}; + +export const duplicateName2Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName2Request(opts) : undefined; + }); +}; + +export const duplicateName3Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName3Request(opts) : undefined; + }); +}; + +export const duplicateName4Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName4Request(opts) : undefined; + }); +}; + +export const callWithNoContentResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithNoContentResponseRequest(opts) : undefined; + }); +}; + +export const callWithResponseAndNoContentResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponseAndNoContentResponseRequest(opts) : undefined; + }); +}; + +export const dummyAResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? dummyARequest(opts) : undefined; + }); +}; + +export const dummyBResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? dummyBRequest(opts) : undefined; + }); +}; + +export const callWithResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponseRequest(opts) : undefined; + }); +}; + +export const callWithDuplicateResponsesResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDuplicateResponsesRequest(opts) : undefined; + }); +}; + +export const callWithResponsesResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponsesRequest(opts) : undefined; + }); +}; + +export const collectionFormatResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? collectionFormatRequest(opts) : undefined; + }); +}; + +export const typesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? typesRequest(opts) : undefined; + }); +}; + +export const complexTypesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? complexTypesRequest(opts) : undefined; + }); +}; + +export const callWithResultFromHeaderResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResultFromHeaderRequest(opts) : undefined; + }); +}; + +export const testErrorCodeResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? testErrorCodeRequest(opts) : undefined; + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串Resource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? nonAsciiæøåÆøÅöôêÊ字符串Request(opts) : undefined; + }); +}; + +/** + * Body should not be unknown + * Body should not be unknown + */ +export const postApiVbyApiVersionBodyResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postApiVbyApiVersionBodyRequest(opts) : undefined; + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts new file mode 100644 index 000000000..2e5fe1c9b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config2) => Config2 & T>; + +export const client = createClient2(createConfig2({ + baseUrl: 'http://localhost:3000/base' +})); + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig2 = (override?: Config) => Config & T>; + +export const client2 = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts new file mode 100644 index 000000000..40c2b65df --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts @@ -0,0 +1,261 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpResponse } from '@angular/common/http'; +import { + HttpClient, + HttpErrorResponse, + HttpEventType, + HttpRequest, +} from '@angular/common/http'; +import { + assertInInjectionContext, + inject, + provideAppInitializer, + runInInjectionContext, +} from '@angular/core'; +import { firstValueFrom } from 'rxjs'; +import { filter } from 'rxjs/operators'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, + ResponseStyle, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export function provideHeyApiClient(client: Client) { + return provideAppInitializer(() => { + const httpClient = inject(HttpClient); + client.setConfig({ httpClient }); + }); +} + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >(); + + const requestOptions = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + options: RequestOptions, + ) => { + const opts = { + ..._config, + ...options, + headers: mergeHeaders(_config.headers, options.headers), + httpClient: options.httpClient ?? _config.httpClient, + serializedBody: undefined, + }; + + if (!opts.httpClient) { + if (opts.injector) { + opts.httpClient = runInInjectionContext(opts.injector, () => + inject(HttpClient), + ); + } else { + assertInInjectionContext(requestOptions); + opts.httpClient = inject(HttpClient); + } + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts as any); + + const req = new HttpRequest( + opts.method ?? 'GET', + url, + getValidRequestBody(opts), + { + redirect: 'follow', + ...opts, + }, + ); + + return { opts, req, url }; + }; + + const beforeRequest = async (options: RequestOptions) => { + const { opts, req, url } = requestOptions(options); + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + return { opts, req, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, req: initialReq } = await beforeRequest(options); + + let req = initialReq; + + for (const fn of interceptors.request._fns) { + if (fn) { + req = await fn(req, opts as any); + } + } + + const result: { + request: HttpRequest; + response: any; + } = { + request: req, + response: null, + }; + + try { + result.response = (await firstValueFrom( + opts + .httpClient!.request(req) + .pipe(filter((event) => event.type === HttpEventType.Response)), + )) as HttpResponse; + + for (const fn of interceptors.response._fns) { + if (fn) { + result.response = await fn(result.response, req, opts as any); + } + } + + let bodyResponse = result.response.body; + + if (opts.responseValidator) { + await opts.responseValidator(bodyResponse); + } + + if (opts.responseTransformer) { + bodyResponse = await opts.responseTransformer(bodyResponse); + } + + return opts.responseStyle === 'data' + ? bodyResponse + : { data: bodyResponse, ...result }; + } catch (error) { + if (error instanceof HttpErrorResponse) { + result.response = error; + } + + let finalError = error instanceof HttpErrorResponse ? error.error : error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn( + finalError, + result.response as any, + req, + opts as any, + )) as string; + } + } + + if (opts.throwOnError) { + throw finalError; + } + + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + requestOptions: (options) => { + if (options.security) { + throw new Error('Security is not supported in requestOptions'); + } + + if (options.requestValidator) { + throw new Error( + 'Request validation is not supported in requestOptions', + ); + } + + return requestOptions(options).req; + }, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..6cdf8ad48 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/types.gen.ts @@ -0,0 +1,283 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + HttpClient, + HttpErrorResponse, + HttpHeaders, + HttpRequest, + HttpResponse, +} from '@angular/common/http'; +import type { Injector } from '@angular/core'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `HttpHeaders` object with. + * + * {@link https://angular.dev/api/common/http/HttpHeaders#constructor See more} + */ + headers?: + | HttpHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The HTTP client to use for making requests. + */ + httpClient?: HttpClient; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + /** + * Optional custom injector for dependency resolution if you don't implicitly or explicitly provide one. + */ + injector?: Injector; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = Promise< + ThrowOnError extends true + ? TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: HttpRequest; + response: HttpResponse; + } + : TResponseStyle extends 'data' + ? + | (TData extends Record ? TData[keyof TData] : TData) + | undefined + : + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + request: HttpRequest; + response: HttpResponse; + } + | { + data: undefined; + error: TError[keyof TError]; + request: HttpRequest; + response: HttpErrorResponse & { + error: TError[keyof TError] | null; + }; + } +>; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type RequestOptionsFn = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: RequestOptions, +) => HttpRequest; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >; + requestOptions: RequestOptionsFn; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts new file mode 100644 index 000000000..3bb799dff --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts @@ -0,0 +1,431 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { HttpHeaders } from '@angular/common/http'; + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +export const setAuthParams = async ( + options: Pick, 'security'> & + Pick & { + headers: HttpHeaders; + }, +) => { + for (const auth of options.security) { + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers = options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers = options.headers.set(name, token); + break; + } + + return; + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): HttpHeaders => { + let mergedHeaders = new HttpHeaders(); + + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + if (header instanceof HttpHeaders) { + // Merge HttpHeaders instance + header.keys().forEach((key) => { + const values = header.getAll(key); + if (values) { + values.forEach((value) => { + mergedHeaders = mergedHeaders.append(key, value); + }); + } + }); + } else { + // Merge plain object headers + for (const [key, value] of Object.entries(header)) { + if (value === null) { + mergedHeaders = mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders = mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders = mergedHeaders.set( + key, + typeof value === 'object' + ? JSON.stringify(value) + : (value as string), + ); + } + } + } + } + + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/sdk.gen.ts new file mode 100644 index 000000000..b215924fa --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/sdk.gen.ts @@ -0,0 +1,277 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, FooWowData, FooWowResponses, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponses, PostApiVbyApiVersionBodyErrors } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const serviceWithEmptyTag = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/descriptions/', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); +}; + +export const callWithDefaultParameters = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + querySerializer: { + array: { + explode: false, + style: 'form' + } + }, + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + querySerializer: { + array: { + explode: false, + style: 'form' + } + }, + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Body should not be unknown + * Body should not be unknown + */ +export const postApiVbyApiVersionBody = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/body', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/types.gen.ts new file mode 100644 index 000000000..b0edf4e79 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/types.gen.ts @@ -0,0 +1,1178 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type ExternalRefA = ExternalSharedExternalSharedModel; + +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + foo?: string; + bar?: string; +}>; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a type-only model that defines Date as a string + */ +export type _Date = string; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp: string | null; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + test?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string; + }; + }; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +export type Default = { + name?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type ParameterActivityParams = { + description?: string; + graduate_id?: number; + organization_id?: number; + parent_activity?: number; + post_id?: number; +}; + +export type ResponsePostActivityResponse = { + description?: string; + graduate_id?: number; + organization_id?: number; + parent_activity_id?: number; + post_id?: number; +}; + +export type FailureFailure = { + error?: string; + message?: string; + reference_code?: string; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type ServiceWithEmptyTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions/'; +}; + +export type CallWithParametersData = { + body?: never; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query: { + /** + * This is the parameter that goes into the query params + */ + parameterQuery: string; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + body?: never; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query: { + /** + * This is a simple string with default value + */ + parameterString: string; + /** + * This is a simple number with default value + */ + parameterNumber: number; + /** + * This is a simple boolean with default value + */ + parameterBoolean: boolean; + /** + * This is a simple enum with default value + */ + parameterEnum: 'Success' | 'Warning' | 'Error'; + /** + * This is a model with one string property + */ + parameterModel: { + /** + * This is a simple string property + */ + prop?: string; + }; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: unknown; +}; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: unknown; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + /** + * Success + */ + 204: unknown; +}; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: unknown; +}; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + /** + * Message for default response + */ + default: ModelWithString; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithString; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithString; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean; + /** + * This is an array parameter + */ + parameterArray: Array; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + }; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error'; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * This is a model with one string property + */ + parameterReference: { + /** + * This is a simple string property + */ + prop?: string; + }; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: string; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: NonAsciiStringæøåÆøÅöôêÊ字符串; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PostApiVbyApiVersionBodyData = { + /** + * Body should not be unknown + */ + body: ParameterActivityParams; + path?: never; + query?: never; + url: '/api/v{api-version}/body'; +}; + +export type PostApiVbyApiVersionBodyErrors = { + /** + * Bad Request + */ + 400: FailureFailure; + /** + * Internal Server Error + */ + 500: FailureFailure; +}; + +export type PostApiVbyApiVersionBodyError = PostApiVbyApiVersionBodyErrors[keyof PostApiVbyApiVersionBodyErrors]; + +export type PostApiVbyApiVersionBodyResponses = { + /** + * OK + */ + 200: ResponsePostActivityResponse; +}; + +export type PostApiVbyApiVersionBodyResponse = PostApiVbyApiVersionBodyResponses[keyof PostApiVbyApiVersionBodyResponses]; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts index 5f6dbe077..24eb1f992 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts @@ -2,21 +2,12 @@ export const ExternalRefASchema = { description: 'External ref to shared model (A)', - type: 'object', - properties: { - id: { - type: 'string' - }, - name: { - type: 'string' - } - }, - required: ['id'] + '$ref': '#/definitions/external-shared_ExternalSharedModel' } as const; export const ExternalRefBSchema = { description: 'External ref to shared model (B)', - '$ref': '#/definitions/ExternalRefA' + '$ref': '#/definitions/external-shared_ExternalSharedModel' } as const; export const CommentWithBreaksSchema = { @@ -689,6 +680,19 @@ export const failure_FailureSchema = { } } as const; +export const external_shared_ExternalSharedModelSchema = { + type: 'object', + properties: { + id: { + type: 'string' + }, + name: { + type: 'string' + } + }, + required: ['id'] +} as const; + export const ModelWithPropertiesWritableSchema = { description: 'This is a model with one nested property', type: 'object', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index 15255213f..742676468 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts index 15255213f..742676468 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts index 15255213f..742676468 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index 15255213f..742676468 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts index 15255213f..742676468 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts index 282f00886..b0edf4e79 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts @@ -1,14 +1,8 @@ // This file is auto-generated by @hey-api/openapi-ts -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -416,6 +410,11 @@ export type FailureFailure = { reference_code?: string; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts index 0eacb3ac9..b7df7b1fe 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts @@ -2,15 +2,14 @@ import * as v from 'valibot'; -/** - * External ref to shared model (A) - */ -export const vExternalRefA = v.object({ +export const vExternalSharedExternalSharedModel = v.object({ id: v.string(), name: v.optional(v.string()) }); -export const vExternalRefB = vExternalRefA; +export const vExternalRefA = vExternalSharedExternalSharedModel; + +export const vExternalRefB = vExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/types.gen.ts index 92ea92c8f..2ab40752d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/types.gen.ts @@ -1,162 +1,178 @@ // This file is auto-generated by @hey-api/openapi-ts -export type ExternalSchemaA = _heyapi_2_; +export type ExternalSchemaA = ExternalSharedExternalSharedModel; -export type ExternalSchemaB = 2; +export type ExternalSchemaB = ExternalSharedExternalSharedModel; -export type ExternalSchemaC = 2; +export type ExternalSchemaC = ExternalSharedExternalSharedModel; -export type ExternalSchemaPathA = 2; +export type ExternalSchemaPathA = ExternalSharedExternalSharedModel; -export type ExternalSchemaPathB = 2; +export type ExternalSchemaPathB = ExternalSharedExternalSharedModel; /** * External schema property (A) */ export type ExternalSchemaPropertyA = { - uuid1?: 3; + uuid1?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property (B) - second use of UUID */ export type ExternalSchemaPropertyB = { - uuid2?: 3; + uuid2?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property (C) - third use of UUID */ export type ExternalSchemaPropertyC = { - uuid3?: 3; + uuid3?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property with duplicate refs (D) */ export type ExternalSchemaPropertyD = { - uuid4?: 3; - uuid5?: 3; + uuid4?: ExternalSharedExternalSharedModelWithUuid; + uuid5?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property via external property ref (id) */ export type ExternalSchemaExternalProp = { - id3?: 4; - id4?: 4; + id3?: ExternalSharedId; + id4?: ExternalSharedId; }; /** * Alias to external property via component property ref */ export type ExternalSchemaExternalPropAlias = { - id5?: 4; - id6?: 4; + id5?: ExternalSharedId; + id6?: ExternalSharedId; }; /** * External double nested prop via property ref */ export type ExternalDoubleNestedProp = { - deep1?: 5; - deep2?: 5; + deep1?: ExternalSharedDeep; + deep2?: ExternalSharedDeep; }; /** * External double nested numeric properties */ export type ExternalDoubleNestedNumeric = { - numeric1?: 6; - numeric2?: 6; + numeric1?: ExternalShared1; + numeric2?: ExternalShared1; }; -export type ExternalNestedObjectA = 7; +export type ExternalNestedObjectA = ExternalSharedExternalNested; -export type ExternalNestedObjectB = 7; +export type ExternalNestedObjectB = ExternalSharedExternalNested; -export type ExternalNestedNumericObjectA = 8; +export type ExternalNestedNumericObjectA = ExternalSharedExternalNestedNumeric; -export type ExternalNestedNumericObjectB = 8; +export type ExternalNestedNumericObjectB = ExternalSharedExternalNestedNumeric; /** * Mixed external property references */ export type ExternalMixedProperties = { - id7?: 4; - name1?: 9; - uuid6?: 3; - deep3?: 5; - numeric3?: 6; + id7?: ExternalSharedId; + name1?: ExternalSharedName; + uuid6?: ExternalSharedExternalSharedModelWithUuid; + deep3?: ExternalSharedDeep; + numeric3?: ExternalShared1; }; /** * Array containing external references */ export type ExternalArraySchema = { - items?: Array<2>; - uuidItems?: Array<3>; + items?: Array; + uuidItems?: Array; }; /** * Union type with external references */ -export type ExternalUnionSchema = { - id: string; - name?: string; -} | 2 | 3; +export type ExternalUnionSchema = ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid; /** * AllOf with external references */ -export type ExternalAllOfSchema = 2 & { - additional?: 3; +export type ExternalAllOfSchema = ExternalSharedExternalSharedModel & { + additional?: ExternalSharedExternalSharedModelWithUuid; }; /** * AnyOf with external references */ -export type ExternalAnyOfSchema = { +export type ExternalAnyOfSchema = ExternalSharedExternalNested | ExternalSharedExternalNestedNumeric; + +export type ExternalSharedExternalNested = { inner?: { deep?: string; }; -} | 7 | { +}; + +export type ExternalSharedDeep = string; + +export type ExternalSharedExternalNestedNumeric = { 0?: { 1?: string; }; -} | 8; +}; + +export type ExternalShared1 = string; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +export type ExternalSharedId = string; + +export type ExternalSharedName = string; + +export type ExternalSharedExternalSharedModelWithUuid = string; -export type ExternalIdParam = 4; +export type ExternalIdParam = ExternalSharedId; -export type ExternalUuidParam = 3; +export type ExternalUuidParam = ExternalSharedExternalSharedModelWithUuid; -export type ExternalDeepParam = 5; +export type ExternalDeepParam = ExternalSharedDeep; -export type ExternalNumericParam = 6; +export type ExternalNumericParam = ExternalShared1; -export type ExternalModelBody = 2; +export type ExternalModelBody = ExternalSharedExternalSharedModel; -export type ExternalUuidBody = 3; +export type ExternalUuidBody = ExternalSharedExternalSharedModelWithUuid; -export type ExternalNestedBody = 7; +export type ExternalNestedBody = ExternalSharedExternalNested; /** * Request body with mixed external properties */ export type ExternalMixedBody = { - id?: 4; - name?: 9; - uuid?: 3; - deep?: 5; + id?: ExternalSharedId; + name?: ExternalSharedName; + uuid?: ExternalSharedExternalSharedModelWithUuid; + deep?: ExternalSharedDeep; }; export type GetExternalModelData = { body?: never; path: { - id: 4; + id: ExternalSharedId; }; query?: { - uuid?: 3; + uuid?: ExternalSharedExternalSharedModelWithUuid; }; url: '/external-model'; }; @@ -165,7 +181,7 @@ export type GetExternalModelErrors = { /** * Response using external UUID */ - 400: 3; + 400: ExternalSharedExternalSharedModelWithUuid; }; export type GetExternalModelError = GetExternalModelErrors[keyof GetExternalModelErrors]; @@ -174,7 +190,7 @@ export type GetExternalModelResponses = { /** * Response using external model */ - 200: 2; + 200: ExternalSharedExternalSharedModel; }; export type GetExternalModelResponse = GetExternalModelResponses[keyof GetExternalModelResponses]; @@ -193,7 +209,7 @@ export type PostExternalModelErrors = { /** * Response with union of external types */ - 422: 2 | 3 | 7; + 422: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; }; export type PostExternalModelError = PostExternalModelErrors[keyof PostExternalModelErrors]; @@ -202,7 +218,7 @@ export type PostExternalModelResponses = { /** * Response using external model */ - 201: 2; + 201: ExternalSharedExternalSharedModel; }; export type PostExternalModelResponse = PostExternalModelResponses[keyof PostExternalModelResponses]; @@ -211,7 +227,7 @@ export type GetExternalUuidData = { body?: never; path?: never; query?: { - uuid?: 3; + uuid?: ExternalSharedExternalSharedModelWithUuid; }; url: '/external-uuid'; }; @@ -220,7 +236,7 @@ export type GetExternalUuidResponses = { /** * Response using external UUID */ - 200: 3; + 200: ExternalSharedExternalSharedModelWithUuid; }; export type GetExternalUuidResponse = GetExternalUuidResponses[keyof GetExternalUuidResponses]; @@ -239,7 +255,7 @@ export type PutExternalUuidResponses = { /** * Response using external UUID */ - 200: 3; + 200: ExternalSharedExternalSharedModelWithUuid; }; export type PutExternalUuidResponse = PutExternalUuidResponses[keyof PutExternalUuidResponses]; @@ -247,7 +263,7 @@ export type PutExternalUuidResponse = PutExternalUuidResponses[keyof PutExternal export type GetExternalNestedData = { body?: never; headers?: { - deep?: 5; + deep?: ExternalSharedDeep; }; path?: never; query?: never; @@ -258,7 +274,7 @@ export type GetExternalNestedResponses = { /** * Response using external nested object */ - 200: 7; + 200: ExternalSharedExternalNested; }; export type GetExternalNestedResponse = GetExternalNestedResponses[keyof GetExternalNestedResponses]; @@ -277,7 +293,7 @@ export type PostExternalNestedResponses = { /** * Response using external nested object */ - 201: 7; + 201: ExternalSharedExternalNested; }; export type PostExternalNestedResponse = PostExternalNestedResponses[keyof PostExternalNestedResponses]; @@ -285,14 +301,14 @@ export type PostExternalNestedResponse = PostExternalNestedResponses[keyof PostE export type GetExternalMixedData = { body?: never; headers?: { - deep?: 5; + deep?: ExternalSharedDeep; }; path: { - id: 4; + id: ExternalSharedId; }; query?: { - uuid?: 3; - numeric?: 6; + uuid?: ExternalSharedExternalSharedModelWithUuid; + numeric?: ExternalShared1; }; url: '/external-mixed'; }; @@ -301,7 +317,7 @@ export type GetExternalMixedResponses = { /** * Response with array of external models */ - 200: Array<2>; + 200: Array; }; export type GetExternalMixedResponse = GetExternalMixedResponses[keyof GetExternalMixedResponses]; @@ -320,7 +336,7 @@ export type PostExternalMixedResponses = { /** * Response using external model */ - 201: 2; + 201: ExternalSharedExternalSharedModel; }; export type PostExternalMixedResponse = PostExternalMixedResponses[keyof PostExternalMixedResponses]; @@ -336,13 +352,13 @@ export type GetExternalArrayResponses = { /** * Response with array of external models */ - 200: Array<2>; + 200: Array; }; export type GetExternalArrayResponse = GetExternalArrayResponses[keyof GetExternalArrayResponses]; export type PostExternalArrayData = { - body: Array<2>; + body: Array; path?: never; query?: never; url: '/external-array'; @@ -352,7 +368,7 @@ export type PostExternalArrayResponses = { /** * Response with array of external models */ - 201: Array<2>; + 201: Array; }; export type PostExternalArrayResponse = PostExternalArrayResponses[keyof PostExternalArrayResponses]; @@ -368,13 +384,13 @@ export type GetExternalUnionResponses = { /** * Response with union of external types */ - 200: 2 | 3 | 7; + 200: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; }; export type GetExternalUnionResponse = GetExternalUnionResponses[keyof GetExternalUnionResponses]; export type PostExternalUnionData = { - body: 2 | 3 | 7; + body: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; path?: never; query?: never; url: '/external-union'; @@ -384,7 +400,7 @@ export type PostExternalUnionResponses = { /** * Response with union of external types */ - 201: 2 | 3 | 7; + 201: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; }; export type PostExternalUnionResponse = PostExternalUnionResponses[keyof PostExternalUnionResponses]; @@ -392,24 +408,24 @@ export type PostExternalUnionResponse = PostExternalUnionResponses[keyof PostExt export type GetExternalPropertiesByIdData = { body?: never; headers?: { - deep?: 5; + deep?: ExternalSharedDeep; }; path: { - id: 4; + id: ExternalSharedId; }; query?: { - uuid?: 3; + uuid?: ExternalSharedExternalSharedModelWithUuid; }; url: '/external-properties/{id}'; }; export type GetExternalPropertiesByIdResponses = { 200: { - id?: 4; - name?: 9; - uuid?: 3; - deep?: 5; - numeric?: 6; + id?: ExternalSharedId; + name?: ExternalSharedName; + uuid?: ExternalSharedExternalSharedModelWithUuid; + deep?: ExternalSharedDeep; + numeric?: ExternalShared1; }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts new file mode 100644 index 000000000..89c7c12b3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts @@ -0,0 +1,607 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpRequest } from '@angular/common/http'; +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, CollectionFormatData, TypesData, UploadFileData, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { client } from '../../../client.gen'; +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultRequests { + public export(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public patchApiVbyApiVersionNoTag(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public import(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public fooWow(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public getApiVbyApiVersionSimpleOperation(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple:operation', + ...options + }); + } +} + +class ODataControllerRequests { + public apiVVersionODataControllerCount(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple/$count', + ...options + }); + } +} + +class VVersionRequests { + oDataController = new ODataControllerRequests(); +} + +class ApiRequests { + vVersion = new VVersionRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleRequests { + public deleteCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public getCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public headCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'HEAD', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public optionsCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public patchCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public postCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public putCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/simple', + ...options + }); + } + api = new ApiRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersRequests { + public deleteFoo(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); + } + + public callWithParameters(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); + } + + public callWithWeirdParameterNames(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); + } + + public getCallWithOptionalParam(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/parameters', + ...options + }); + } + + public postCallWithOptionalParam(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsRequests { + public callWithDescriptions(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/descriptions', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DeprecatedRequests { + /** + * @deprecated + */ + public deprecatedCall(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class RequestBodyRequests { + public postApiVbyApiVersionRequestBody(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/requestBody', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FormDataRequests { + public postApiVbyApiVersionFormData(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/formData', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsRequests { + public callWithDefaultParameters(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/defaults', + ...options + }); + } + + public callWithDefaultOptionalParameters(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/defaults', + ...options + }); + } + + public callToTestOrderOfParams(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/defaults', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateRequests { + public duplicateName(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName2(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName3(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName4(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/duplicate', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentRequests { + public callWithNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no-content', + ...options + }); + } + + public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseRequests { + public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); + } + + public callWithResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/response', + ...options + }); + } + + public callWithDuplicateResponses(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/response', + ...options + }); + } + + public callWithResponses(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/response', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1Requests { + public dummyA(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); + } + + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2Requests { + public dummyA(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); + } + + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3Requests { + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatRequests { + public collectionFormat(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesRequests { + public types(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/types', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class UploadRequests { + public uploadFile(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/upload', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FileResponseRequests { + public fileResponse(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/file/{id}', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexRequests { + public complexTypes(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/complex', + ...options + }); + } + + public complexParams(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/complex/{id}', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipartRequests { + public multipartResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multipart', + ...options + }); + } + + public multipartRequest(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/multipart', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderRequests { + public callWithResultFromHeader(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/header', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorRequests { + public testErrorCode(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/error', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊRequests { + public nonAsciiæøåÆøÅöôêÊ字符串(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); + } + + /** + * Login User + */ + public putWithFormUrlEncoded(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts new file mode 100644 index 000000000..c4b0e6215 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts @@ -0,0 +1,503 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { httpResource } from '@angular/common/http'; +import { DefaultRequests, SimpleRequests, ParametersRequests, DescriptionsRequests, DeprecatedRequests, RequestBodyRequests, FormDataRequests, DefaultsRequests, DuplicateRequests, NoContentRequests, ResponseRequests, MultipleTags1Requests, CollectionFormatRequests, TypesRequests, UploadRequests, FileResponseRequests, ComplexRequests, MultipartRequests, HeaderRequests, ErrorRequests, NonAsciiÆøåÆøÅöôêÊRequests } from './requests.gen'; +import { inject, Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultResources { + public export(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).export(opts) : undefined; + }); + } + + public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + }); + } + + public import(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).import(opts) : undefined; + }); + } + + public fooWow(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).fooWow(opts) : undefined; + }); + } + + public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; + }); + } +} + +class ODataControllerResources { + public apiVVersionODataControllerCount(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).api.vVersion.oDataController.apiVVersionODataControllerCount(opts) : undefined; + }); + } +} + +class VVersionResources { + oDataController = new ODataControllerResources(); +} + +class ApiResources { + vVersion = new VVersionResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleResources { + public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).getCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).headCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).postCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).putCallWithoutParametersAndResponse(opts) : undefined; + }); + } + api = new ApiResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersResources { + public deleteFoo(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).deleteFoo(opts) : undefined; + }); + } + + public callWithParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).callWithParameters(opts) : undefined; + }); + } + + public callWithWeirdParameterNames(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).callWithWeirdParameterNames(opts) : undefined; + }); + } + + public getCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).getCallWithOptionalParam(opts) : undefined; + }); + } + + public postCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).postCallWithOptionalParam(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsResources { + public callWithDescriptions(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DescriptionsRequests).callWithDescriptions(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DeprecatedResources { + /** + * @deprecated + */ + public deprecatedCall(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DeprecatedRequests).deprecatedCall(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class RequestBodyResources { + public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(RequestBodyRequests).postApiVbyApiVersionRequestBody(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FormDataResources { + public postApiVbyApiVersionFormData(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FormDataRequests).postApiVbyApiVersionFormData(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsResources { + public callWithDefaultParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callWithDefaultParameters(opts) : undefined; + }); + } + + public callWithDefaultOptionalParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callWithDefaultOptionalParameters(opts) : undefined; + }); + } + + public callToTestOrderOfParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callToTestOrderOfParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateResources { + public duplicateName(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName(opts) : undefined; + }); + } + + public duplicateName2(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName2(opts) : undefined; + }); + } + + public duplicateName3(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName3(opts) : undefined; + }); + } + + public duplicateName4(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName4(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentResources { + public callWithNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NoContentRequests).callWithNoContentResponse(opts) : undefined; + }); + } + + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseResources { + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } + + public callWithResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponse(opts) : undefined; + }); + } + + public callWithDuplicateResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithDuplicateResponses(opts) : undefined; + }); + } + + public callWithResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponses(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1Resources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2Resources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3Resources { + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatResources { + public collectionFormat(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(CollectionFormatRequests).collectionFormat(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesResources { + public types(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(TypesRequests).types(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class UploadResources { + public uploadFile(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(UploadRequests).uploadFile(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FileResponseResources { + public fileResponse(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FileResponseRequests).fileResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexResources { + public complexTypes(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexRequests).complexTypes(opts) : undefined; + }); + } + + public complexParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexRequests).complexParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipartResources { + public multipartResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartRequests).multipartResponse(opts) : undefined; + }); + } + + public multipartRequest(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartRequests).multipartRequest(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderResources { + public callWithResultFromHeader(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(HeaderRequests).callWithResultFromHeader(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorResources { + public testErrorCode(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ErrorRequests).testErrorCode(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊResources { + public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + }); + } + + /** + * Login User + */ + public putWithFormUrlEncoded(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).putWithFormUrlEncoded(opts) : undefined; + }); + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts new file mode 100644 index 000000000..2e5fe1c9b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config2) => Config2 & T>; + +export const client = createClient2(createConfig2({ + baseUrl: 'http://localhost:3000/base' +})); + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig2 = (override?: Config) => Config & T>; + +export const client2 = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts new file mode 100644 index 000000000..40c2b65df --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -0,0 +1,261 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpResponse } from '@angular/common/http'; +import { + HttpClient, + HttpErrorResponse, + HttpEventType, + HttpRequest, +} from '@angular/common/http'; +import { + assertInInjectionContext, + inject, + provideAppInitializer, + runInInjectionContext, +} from '@angular/core'; +import { firstValueFrom } from 'rxjs'; +import { filter } from 'rxjs/operators'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, + ResponseStyle, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export function provideHeyApiClient(client: Client) { + return provideAppInitializer(() => { + const httpClient = inject(HttpClient); + client.setConfig({ httpClient }); + }); +} + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >(); + + const requestOptions = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + options: RequestOptions, + ) => { + const opts = { + ..._config, + ...options, + headers: mergeHeaders(_config.headers, options.headers), + httpClient: options.httpClient ?? _config.httpClient, + serializedBody: undefined, + }; + + if (!opts.httpClient) { + if (opts.injector) { + opts.httpClient = runInInjectionContext(opts.injector, () => + inject(HttpClient), + ); + } else { + assertInInjectionContext(requestOptions); + opts.httpClient = inject(HttpClient); + } + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts as any); + + const req = new HttpRequest( + opts.method ?? 'GET', + url, + getValidRequestBody(opts), + { + redirect: 'follow', + ...opts, + }, + ); + + return { opts, req, url }; + }; + + const beforeRequest = async (options: RequestOptions) => { + const { opts, req, url } = requestOptions(options); + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + return { opts, req, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, req: initialReq } = await beforeRequest(options); + + let req = initialReq; + + for (const fn of interceptors.request._fns) { + if (fn) { + req = await fn(req, opts as any); + } + } + + const result: { + request: HttpRequest; + response: any; + } = { + request: req, + response: null, + }; + + try { + result.response = (await firstValueFrom( + opts + .httpClient!.request(req) + .pipe(filter((event) => event.type === HttpEventType.Response)), + )) as HttpResponse; + + for (const fn of interceptors.response._fns) { + if (fn) { + result.response = await fn(result.response, req, opts as any); + } + } + + let bodyResponse = result.response.body; + + if (opts.responseValidator) { + await opts.responseValidator(bodyResponse); + } + + if (opts.responseTransformer) { + bodyResponse = await opts.responseTransformer(bodyResponse); + } + + return opts.responseStyle === 'data' + ? bodyResponse + : { data: bodyResponse, ...result }; + } catch (error) { + if (error instanceof HttpErrorResponse) { + result.response = error; + } + + let finalError = error instanceof HttpErrorResponse ? error.error : error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn( + finalError, + result.response as any, + req, + opts as any, + )) as string; + } + } + + if (opts.throwOnError) { + throw finalError; + } + + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + requestOptions: (options) => { + if (options.security) { + throw new Error('Security is not supported in requestOptions'); + } + + if (options.requestValidator) { + throw new Error( + 'Request validation is not supported in requestOptions', + ); + } + + return requestOptions(options).req; + }, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..6cdf8ad48 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/types.gen.ts @@ -0,0 +1,283 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + HttpClient, + HttpErrorResponse, + HttpHeaders, + HttpRequest, + HttpResponse, +} from '@angular/common/http'; +import type { Injector } from '@angular/core'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `HttpHeaders` object with. + * + * {@link https://angular.dev/api/common/http/HttpHeaders#constructor See more} + */ + headers?: + | HttpHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The HTTP client to use for making requests. + */ + httpClient?: HttpClient; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + /** + * Optional custom injector for dependency resolution if you don't implicitly or explicitly provide one. + */ + injector?: Injector; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = Promise< + ThrowOnError extends true + ? TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: HttpRequest; + response: HttpResponse; + } + : TResponseStyle extends 'data' + ? + | (TData extends Record ? TData[keyof TData] : TData) + | undefined + : + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + request: HttpRequest; + response: HttpResponse; + } + | { + data: undefined; + error: TError[keyof TError]; + request: HttpRequest; + response: HttpErrorResponse & { + error: TError[keyof TError] | null; + }; + } +>; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type RequestOptionsFn = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: RequestOptions, +) => HttpRequest; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >; + requestOptions: RequestOptionsFn; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts new file mode 100644 index 000000000..3bb799dff --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts @@ -0,0 +1,431 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { HttpHeaders } from '@angular/common/http'; + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +export const setAuthParams = async ( + options: Pick, 'security'> & + Pick & { + headers: HttpHeaders; + }, +) => { + for (const auth of options.security) { + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers = options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers = options.headers.set(name, token); + break; + } + + return; + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): HttpHeaders => { + let mergedHeaders = new HttpHeaders(); + + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + if (header instanceof HttpHeaders) { + // Merge HttpHeaders instance + header.keys().forEach((key) => { + const values = header.getAll(key); + if (values) { + values.forEach((value) => { + mergedHeaders = mergedHeaders.append(key, value); + }); + } + }); + } else { + // Merge plain object headers + for (const [key, value] of Object.entries(header)) { + if (value === null) { + mergedHeaders = mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders = mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders = mergedHeaders.set( + key, + typeof value === 'object' + ? JSON.stringify(value) + : (value as string), + ); + } + } + } + } + + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/sdk.gen.ts new file mode 100644 index 000000000..17622c66b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/types.gen.ts new file mode 100644 index 000000000..7fddaa46d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/types.gen.ts @@ -0,0 +1,2046 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +export type ExternalRefA = ExternalSharedExternalSharedModel; + +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: unknown; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = Array; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +export type SimpleRequestBody = ModelWithString; + +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error'; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts new file mode 100644 index 000000000..e7b3678ca --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts @@ -0,0 +1,444 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpRequest } from '@angular/common/http'; +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, CollectionFormatData, TypesData, UploadFileData, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { client } from '../../../client.gen'; + +export const exportRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTagRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const importRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const fooWowRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCountRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperationRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'HEAD', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFooRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptionsRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCallRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParametersRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); +}; + +export const callWithWeirdParameterNamesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); +}; + +export const getCallWithOptionalParamRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/parameters', + ...options + }); +}; + +export const postCallWithOptionalParamRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters', + ...options + }); +}; + +export const postApiVbyApiVersionRequestBodyRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/requestBody', + ...options + }); +}; + +export const postApiVbyApiVersionFormDataRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/formData', + ...options + }); +}; + +export const callWithDefaultParametersRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParametersRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParamsRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateNameRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyARequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyBRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponsesRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponsesRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormatRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const typesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFileRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/upload', + ...options + }); +}; + +export const fileResponseRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequestRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const complexParamsRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/complex/{id}', + ...options + }); +}; + +export const callWithResultFromHeaderRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCodeRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串Request = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncodedRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts new file mode 100644 index 000000000..a6d4fdd5b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts @@ -0,0 +1,348 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { httpResource } from '@angular/common/http'; +import { exportRequest, patchApiVbyApiVersionNoTagRequest, importRequest, fooWowRequest, apiVVersionODataControllerCountRequest, getApiVbyApiVersionSimpleOperationRequest, deleteCallWithoutParametersAndResponseRequest, getCallWithoutParametersAndResponseRequest, headCallWithoutParametersAndResponseRequest, optionsCallWithoutParametersAndResponseRequest, patchCallWithoutParametersAndResponseRequest, postCallWithoutParametersAndResponseRequest, putCallWithoutParametersAndResponseRequest, deleteFooRequest, callWithDescriptionsRequest, deprecatedCallRequest, callWithParametersRequest, callWithWeirdParameterNamesRequest, getCallWithOptionalParamRequest, postCallWithOptionalParamRequest, postApiVbyApiVersionRequestBodyRequest, postApiVbyApiVersionFormDataRequest, callWithDefaultParametersRequest, callWithDefaultOptionalParametersRequest, callToTestOrderOfParamsRequest, duplicateNameRequest, duplicateName2Request, duplicateName3Request, duplicateName4Request, callWithNoContentResponseRequest, callWithResponseAndNoContentResponseRequest, dummyARequest, dummyBRequest, callWithResponseRequest, callWithDuplicateResponsesRequest, callWithResponsesRequest, collectionFormatRequest, typesRequest, uploadFileRequest, fileResponseRequest, complexTypesRequest, multipartResponseRequest, multipartRequestRequest, complexParamsRequest, callWithResultFromHeaderRequest, testErrorCodeRequest, nonAsciiæøåÆøÅöôêÊ字符串Request, putWithFormUrlEncodedRequest } from './requests.gen'; + +export const exportResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? exportRequest(opts) : undefined; + }); +}; + +export const patchApiVbyApiVersionNoTagResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? patchApiVbyApiVersionNoTagRequest(opts) : undefined; + }); +}; + +export const importResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? importRequest(opts) : undefined; + }); +}; + +export const fooWowResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? fooWowRequest(opts) : undefined; + }); +}; + +export const apiVVersionODataControllerCountResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? apiVVersionODataControllerCountRequest(opts) : undefined; + }); +}; + +export const getApiVbyApiVersionSimpleOperationResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? getApiVbyApiVersionSimpleOperationRequest(opts) : undefined; + }); +}; + +export const deleteCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? deleteCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const getCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? getCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const headCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? headCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const optionsCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? optionsCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const patchCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? patchCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const postCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const putCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? putCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const deleteFooResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? deleteFooRequest(opts) : undefined; + }); +}; + +export const callWithDescriptionsResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDescriptionsRequest(opts) : undefined; + }); +}; + +/** + * @deprecated + */ +export const deprecatedCallResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? deprecatedCallRequest(opts) : undefined; + }); +}; + +export const callWithParametersResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithParametersRequest(opts) : undefined; + }); +}; + +export const callWithWeirdParameterNamesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithWeirdParameterNamesRequest(opts) : undefined; + }); +}; + +export const getCallWithOptionalParamResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? getCallWithOptionalParamRequest(opts) : undefined; + }); +}; + +export const postCallWithOptionalParamResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postCallWithOptionalParamRequest(opts) : undefined; + }); +}; + +export const postApiVbyApiVersionRequestBodyResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postApiVbyApiVersionRequestBodyRequest(opts) : undefined; + }); +}; + +export const postApiVbyApiVersionFormDataResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postApiVbyApiVersionFormDataRequest(opts) : undefined; + }); +}; + +export const callWithDefaultParametersResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDefaultParametersRequest(opts) : undefined; + }); +}; + +export const callWithDefaultOptionalParametersResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDefaultOptionalParametersRequest(opts) : undefined; + }); +}; + +export const callToTestOrderOfParamsResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callToTestOrderOfParamsRequest(opts) : undefined; + }); +}; + +export const duplicateNameResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateNameRequest(opts) : undefined; + }); +}; + +export const duplicateName2Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName2Request(opts) : undefined; + }); +}; + +export const duplicateName3Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName3Request(opts) : undefined; + }); +}; + +export const duplicateName4Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName4Request(opts) : undefined; + }); +}; + +export const callWithNoContentResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithNoContentResponseRequest(opts) : undefined; + }); +}; + +export const callWithResponseAndNoContentResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponseAndNoContentResponseRequest(opts) : undefined; + }); +}; + +export const dummyAResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? dummyARequest(opts) : undefined; + }); +}; + +export const dummyBResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? dummyBRequest(opts) : undefined; + }); +}; + +export const callWithResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponseRequest(opts) : undefined; + }); +}; + +export const callWithDuplicateResponsesResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDuplicateResponsesRequest(opts) : undefined; + }); +}; + +export const callWithResponsesResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponsesRequest(opts) : undefined; + }); +}; + +export const collectionFormatResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? collectionFormatRequest(opts) : undefined; + }); +}; + +export const typesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? typesRequest(opts) : undefined; + }); +}; + +export const uploadFileResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? uploadFileRequest(opts) : undefined; + }); +}; + +export const fileResponseResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? fileResponseRequest(opts) : undefined; + }); +}; + +export const complexTypesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? complexTypesRequest(opts) : undefined; + }); +}; + +export const multipartResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? multipartResponseRequest(opts) : undefined; + }); +}; + +export const multipartRequestResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? multipartRequestRequest(opts) : undefined; + }); +}; + +export const complexParamsResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? complexParamsRequest(opts) : undefined; + }); +}; + +export const callWithResultFromHeaderResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResultFromHeaderRequest(opts) : undefined; + }); +}; + +export const testErrorCodeResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? testErrorCodeRequest(opts) : undefined; + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串Resource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? nonAsciiæøåÆøÅöôêÊ字符串Request(opts) : undefined; + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncodedResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? putWithFormUrlEncodedRequest(opts) : undefined; + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts new file mode 100644 index 000000000..2e5fe1c9b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config2) => Config2 & T>; + +export const client = createClient2(createConfig2({ + baseUrl: 'http://localhost:3000/base' +})); + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig2 = (override?: Config) => Config & T>; + +export const client2 = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts new file mode 100644 index 000000000..40c2b65df --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts @@ -0,0 +1,261 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpResponse } from '@angular/common/http'; +import { + HttpClient, + HttpErrorResponse, + HttpEventType, + HttpRequest, +} from '@angular/common/http'; +import { + assertInInjectionContext, + inject, + provideAppInitializer, + runInInjectionContext, +} from '@angular/core'; +import { firstValueFrom } from 'rxjs'; +import { filter } from 'rxjs/operators'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, + ResponseStyle, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export function provideHeyApiClient(client: Client) { + return provideAppInitializer(() => { + const httpClient = inject(HttpClient); + client.setConfig({ httpClient }); + }); +} + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >(); + + const requestOptions = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + options: RequestOptions, + ) => { + const opts = { + ..._config, + ...options, + headers: mergeHeaders(_config.headers, options.headers), + httpClient: options.httpClient ?? _config.httpClient, + serializedBody: undefined, + }; + + if (!opts.httpClient) { + if (opts.injector) { + opts.httpClient = runInInjectionContext(opts.injector, () => + inject(HttpClient), + ); + } else { + assertInInjectionContext(requestOptions); + opts.httpClient = inject(HttpClient); + } + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts as any); + + const req = new HttpRequest( + opts.method ?? 'GET', + url, + getValidRequestBody(opts), + { + redirect: 'follow', + ...opts, + }, + ); + + return { opts, req, url }; + }; + + const beforeRequest = async (options: RequestOptions) => { + const { opts, req, url } = requestOptions(options); + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + return { opts, req, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, req: initialReq } = await beforeRequest(options); + + let req = initialReq; + + for (const fn of interceptors.request._fns) { + if (fn) { + req = await fn(req, opts as any); + } + } + + const result: { + request: HttpRequest; + response: any; + } = { + request: req, + response: null, + }; + + try { + result.response = (await firstValueFrom( + opts + .httpClient!.request(req) + .pipe(filter((event) => event.type === HttpEventType.Response)), + )) as HttpResponse; + + for (const fn of interceptors.response._fns) { + if (fn) { + result.response = await fn(result.response, req, opts as any); + } + } + + let bodyResponse = result.response.body; + + if (opts.responseValidator) { + await opts.responseValidator(bodyResponse); + } + + if (opts.responseTransformer) { + bodyResponse = await opts.responseTransformer(bodyResponse); + } + + return opts.responseStyle === 'data' + ? bodyResponse + : { data: bodyResponse, ...result }; + } catch (error) { + if (error instanceof HttpErrorResponse) { + result.response = error; + } + + let finalError = error instanceof HttpErrorResponse ? error.error : error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn( + finalError, + result.response as any, + req, + opts as any, + )) as string; + } + } + + if (opts.throwOnError) { + throw finalError; + } + + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + requestOptions: (options) => { + if (options.security) { + throw new Error('Security is not supported in requestOptions'); + } + + if (options.requestValidator) { + throw new Error( + 'Request validation is not supported in requestOptions', + ); + } + + return requestOptions(options).req; + }, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..6cdf8ad48 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/types.gen.ts @@ -0,0 +1,283 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + HttpClient, + HttpErrorResponse, + HttpHeaders, + HttpRequest, + HttpResponse, +} from '@angular/common/http'; +import type { Injector } from '@angular/core'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `HttpHeaders` object with. + * + * {@link https://angular.dev/api/common/http/HttpHeaders#constructor See more} + */ + headers?: + | HttpHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The HTTP client to use for making requests. + */ + httpClient?: HttpClient; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + /** + * Optional custom injector for dependency resolution if you don't implicitly or explicitly provide one. + */ + injector?: Injector; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = Promise< + ThrowOnError extends true + ? TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: HttpRequest; + response: HttpResponse; + } + : TResponseStyle extends 'data' + ? + | (TData extends Record ? TData[keyof TData] : TData) + | undefined + : + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + request: HttpRequest; + response: HttpResponse; + } + | { + data: undefined; + error: TError[keyof TError]; + request: HttpRequest; + response: HttpErrorResponse & { + error: TError[keyof TError] | null; + }; + } +>; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type RequestOptionsFn = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: RequestOptions, +) => HttpRequest; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >; + requestOptions: RequestOptionsFn; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts new file mode 100644 index 000000000..3bb799dff --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts @@ -0,0 +1,431 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { HttpHeaders } from '@angular/common/http'; + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +export const setAuthParams = async ( + options: Pick, 'security'> & + Pick & { + headers: HttpHeaders; + }, +) => { + for (const auth of options.security) { + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers = options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers = options.headers.set(name, token); + break; + } + + return; + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): HttpHeaders => { + let mergedHeaders = new HttpHeaders(); + + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + if (header instanceof HttpHeaders) { + // Merge HttpHeaders instance + header.keys().forEach((key) => { + const values = header.getAll(key); + if (values) { + values.forEach((value) => { + mergedHeaders = mergedHeaders.append(key, value); + }); + } + }); + } else { + // Merge plain object headers + for (const [key, value] of Object.entries(header)) { + if (value === null) { + mergedHeaders = mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders = mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders = mergedHeaders.set( + key, + typeof value === 'object' + ? JSON.stringify(value) + : (value as string), + ); + } + } + } + } + + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/sdk.gen.ts new file mode 100644 index 000000000..17622c66b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/types.gen.ts new file mode 100644 index 000000000..7fddaa46d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/types.gen.ts @@ -0,0 +1,2046 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +export type ExternalRefA = ExternalSharedExternalSharedModel; + +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: unknown; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = Array; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +export type SimpleRequestBody = ModelWithString; + +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error'; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts index d898f11be..9c91e2e6f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/schemas/default/schemas.gen.ts @@ -7,21 +7,12 @@ export const _400Schema = { export const ExternalRefASchema = { description: 'External ref to shared model (A)', - type: 'object', - properties: { - id: { - type: 'string' - }, - name: { - type: 'string' - } - }, - required: ['id'] + '$ref': '#/components/schemas/external-shared_ExternalSharedModel' } as const; export const ExternalRefBSchema = { description: 'External ref to shared model (B)', - '$ref': '#/components/schemas/ExternalRefA' + '$ref': '#/components/schemas/external-shared_ExternalSharedModel' } as const; export const camelCaseCommentWithBreaksSchema = { @@ -1999,6 +1990,19 @@ export const Generic_Schema_Duplicate_Issue_1_System_String_Schema = { additionalProperties: false } as const; +export const external_shared_ExternalSharedModelSchema = { + type: 'object', + properties: { + id: { + type: 'string' + }, + name: { + type: 'string' + } + }, + required: ['id'] +} as const; + export const ModelWithPropertiesWritableSchema = { description: 'This is a model with one nested property', type: 'object', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index e0f7d1b85..d45c1ce28 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts index e0f7d1b85..d45c1ce28 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts index e0f7d1b85..d45c1ce28 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index e0f7d1b85..d45c1ce28 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts index e0f7d1b85..d45c1ce28 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts index ff245bffa..7fddaa46d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/fastify/default/types.gen.ts @@ -5,15 +5,9 @@ */ export type _400 = string; -/** - * External ref to shared model (A) - */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -964,6 +958,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts index e04c6d28c..9a36fdf3f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts @@ -7,15 +7,14 @@ import * as v from 'valibot'; */ export const v400 = v.string(); -/** - * External ref to shared model (A) - */ -export const vExternalRefA = v.object({ +export const vExternalSharedExternalSharedModel = v.object({ id: v.string(), name: v.optional(v.string()) }); -export const vExternalRefB = vExternalRefA; +export const vExternalRefA = vExternalSharedExternalSharedModel; + +export const vExternalRefB = vExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts index 787fcdc28..9e134c9a8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/clean-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts index 2b262d1b4..e671e5b13 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts index 2b262d1b4..e671e5b13 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts index 787fcdc28..9e134c9a8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/clean-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts index 2b262d1b4..e671e5b13 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts index 2b262d1b4..e671e5b13 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/types.gen.ts index 51e681794..fb7cc6bd2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/types.gen.ts @@ -3,196 +3,212 @@ /** * External schema (A) */ -export type ExternalSchemaA = _heyapi_2_; +export type ExternalSchemaA = ExternalSharedExternalSharedModel; /** * External schema (B) - second use of ExternalSharedModel */ -export type ExternalSchemaB = 2; +export type ExternalSchemaB = ExternalSharedExternalSharedModel; /** * External schema (C) - third use of ExternalSharedModel */ -export type ExternalSchemaC = 2; +export type ExternalSchemaC = ExternalSharedExternalSharedModel; /** * External schema via path reference (A) */ -export type ExternalSchemaPathA = 2; +export type ExternalSchemaPathA = ExternalSharedExternalSharedModel; /** * External schema via path reference (B) - second use */ -export type ExternalSchemaPathB = 2; +export type ExternalSchemaPathB = ExternalSharedExternalSharedModel; /** * External schema property (A) */ export type ExternalSchemaPropertyA = { - uuid1?: 3; + uuid1?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property (B) - second use of UUID */ export type ExternalSchemaPropertyB = { - uuid2?: 3; + uuid2?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property (C) - third use of UUID */ export type ExternalSchemaPropertyC = { - uuid3?: 3; + uuid3?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property with duplicate refs (D) */ export type ExternalSchemaPropertyD = { - uuid4?: 3; - uuid5?: 3; + uuid4?: ExternalSharedExternalSharedModelWithUuid; + uuid5?: ExternalSharedExternalSharedModelWithUuid; }; /** * External schema property via external property ref (id) */ export type ExternalSchemaExternalProp = { - id3?: 4; - id4?: 4; + id3?: ExternalSharedId; + id4?: ExternalSharedId; }; /** * Alias to external property via component property ref */ export type ExternalSchemaExternalPropAlias = { - id5?: 4; - id6?: 4; + id5?: ExternalSharedId; + id6?: ExternalSharedId; }; /** * External double nested prop via property ref */ export type ExternalDoubleNestedProp = { - deep1?: 5; - deep2?: 5; + deep1?: ExternalSharedDeep; + deep2?: ExternalSharedDeep; }; /** * External double nested numeric properties */ export type ExternalDoubleNestedNumeric = { - numeric1?: 6; - numeric2?: 6; + numeric1?: ExternalShared1; + numeric2?: ExternalShared1; }; /** * External nested object reference (A) */ -export type ExternalNestedObjectA = 7; +export type ExternalNestedObjectA = ExternalSharedExternalNested; /** * External nested object reference (B) - second use */ -export type ExternalNestedObjectB = 7; +export type ExternalNestedObjectB = ExternalSharedExternalNested; /** * External numeric nested object reference (A) */ -export type ExternalNestedNumericObjectA = 8; +export type ExternalNestedNumericObjectA = ExternalSharedExternalNestedNumeric; /** * External numeric nested object reference (B) - second use */ -export type ExternalNestedNumericObjectB = 8; +export type ExternalNestedNumericObjectB = ExternalSharedExternalNestedNumeric; /** * Mixed external property references */ export type ExternalMixedProperties = { - id7?: 4; - name1?: 9; - uuid6?: 3; - deep3?: 5; - numeric3?: 6; + id7?: ExternalSharedId; + name1?: ExternalSharedName; + uuid6?: ExternalSharedExternalSharedModelWithUuid; + deep3?: ExternalSharedDeep; + numeric3?: ExternalShared1; }; /** * Array containing external references */ export type ExternalArraySchema = { - items?: Array<2>; - uuidItems?: Array<3>; + items?: Array; + uuidItems?: Array; }; /** * Union type with external references */ -export type ExternalUnionSchema = { - id: string; - name?: string; -} | 2 | 3; +export type ExternalUnionSchema = ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid; /** * AllOf with external references */ -export type ExternalAllOfSchema = 2 & { - additional?: 3; +export type ExternalAllOfSchema = ExternalSharedExternalSharedModel & { + additional?: ExternalSharedExternalSharedModelWithUuid; }; /** * AnyOf with external references */ -export type ExternalAnyOfSchema = { +export type ExternalAnyOfSchema = ExternalSharedExternalNested | ExternalSharedExternalNestedNumeric; + +export type ExternalSharedExternalNested = { inner?: { deep?: string; }; -} | 7 | { +}; + +export type ExternalSharedDeep = string; + +export type ExternalSharedExternalNestedNumeric = { 0?: { 1?: string; }; -} | 8; +}; + +export type ExternalShared1 = string; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +export type ExternalSharedId = string; + +export type ExternalSharedName = string; + +export type ExternalSharedExternalSharedModelWithUuid = string; -export type ExternalIdParam = 4; +export type ExternalIdParam = ExternalSharedId; -export type ExternalUuidParam = 3; +export type ExternalUuidParam = ExternalSharedExternalSharedModelWithUuid; -export type ExternalDeepParam = 5; +export type ExternalDeepParam = ExternalSharedDeep; -export type ExternalNumericParam = 6; +export type ExternalNumericParam = ExternalShared1; /** * Request body using external model */ -export type ExternalModelBody = 2; +export type ExternalModelBody = ExternalSharedExternalSharedModel; /** * Request body using external UUID */ -export type ExternalUuidBody = 3; +export type ExternalUuidBody = ExternalSharedExternalSharedModelWithUuid; /** * Request body using external nested object */ -export type ExternalNestedBody = 7; +export type ExternalNestedBody = ExternalSharedExternalNested; /** * Request body with mixed external properties */ export type ExternalMixedBody = { - id?: 4; - name?: 9; - uuid?: 3; - deep?: 5; + id?: ExternalSharedId; + name?: ExternalSharedName; + uuid?: ExternalSharedExternalSharedModelWithUuid; + deep?: ExternalSharedDeep; }; export type GetExternalModelData = { body?: never; path: { - id: 4; + id: ExternalSharedId; }; query?: { - uuid?: 3; + uuid?: ExternalSharedExternalSharedModelWithUuid; }; url: '/external-model'; }; @@ -201,7 +217,7 @@ export type GetExternalModelErrors = { /** * Response using external UUID */ - 400: 3; + 400: ExternalSharedExternalSharedModelWithUuid; }; export type GetExternalModelError = GetExternalModelErrors[keyof GetExternalModelErrors]; @@ -210,7 +226,7 @@ export type GetExternalModelResponses = { /** * Response using external model */ - 200: 2; + 200: ExternalSharedExternalSharedModel; }; export type GetExternalModelResponse = GetExternalModelResponses[keyof GetExternalModelResponses]; @@ -229,7 +245,7 @@ export type PostExternalModelErrors = { /** * Response with union of external types */ - 422: 2 | 3 | 7; + 422: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; }; export type PostExternalModelError = PostExternalModelErrors[keyof PostExternalModelErrors]; @@ -238,7 +254,7 @@ export type PostExternalModelResponses = { /** * Response using external model */ - 201: 2; + 201: ExternalSharedExternalSharedModel; }; export type PostExternalModelResponse = PostExternalModelResponses[keyof PostExternalModelResponses]; @@ -247,7 +263,7 @@ export type GetExternalUuidData = { body?: never; path?: never; query?: { - uuid?: 3; + uuid?: ExternalSharedExternalSharedModelWithUuid; }; url: '/external-uuid'; }; @@ -256,7 +272,7 @@ export type GetExternalUuidResponses = { /** * Response using external UUID */ - 200: 3; + 200: ExternalSharedExternalSharedModelWithUuid; }; export type GetExternalUuidResponse = GetExternalUuidResponses[keyof GetExternalUuidResponses]; @@ -275,7 +291,7 @@ export type PutExternalUuidResponses = { /** * Response using external UUID */ - 200: 3; + 200: ExternalSharedExternalSharedModelWithUuid; }; export type PutExternalUuidResponse = PutExternalUuidResponses[keyof PutExternalUuidResponses]; @@ -283,7 +299,7 @@ export type PutExternalUuidResponse = PutExternalUuidResponses[keyof PutExternal export type GetExternalNestedData = { body?: never; headers?: { - deep?: 5; + deep?: ExternalSharedDeep; }; path?: never; query?: never; @@ -294,7 +310,7 @@ export type GetExternalNestedResponses = { /** * Response using external nested object */ - 200: 7; + 200: ExternalSharedExternalNested; }; export type GetExternalNestedResponse = GetExternalNestedResponses[keyof GetExternalNestedResponses]; @@ -313,7 +329,7 @@ export type PostExternalNestedResponses = { /** * Response using external nested object */ - 201: 7; + 201: ExternalSharedExternalNested; }; export type PostExternalNestedResponse = PostExternalNestedResponses[keyof PostExternalNestedResponses]; @@ -321,14 +337,14 @@ export type PostExternalNestedResponse = PostExternalNestedResponses[keyof PostE export type GetExternalMixedData = { body?: never; headers?: { - deep?: 5; + deep?: ExternalSharedDeep; }; path: { - id: 4; + id: ExternalSharedId; }; query?: { - uuid?: 3; - numeric?: 6; + uuid?: ExternalSharedExternalSharedModelWithUuid; + numeric?: ExternalShared1; }; url: '/external-mixed'; }; @@ -337,7 +353,7 @@ export type GetExternalMixedResponses = { /** * Response with array of external models */ - 200: Array<2>; + 200: Array; }; export type GetExternalMixedResponse = GetExternalMixedResponses[keyof GetExternalMixedResponses]; @@ -356,7 +372,7 @@ export type PostExternalMixedResponses = { /** * Response using external model */ - 201: 2; + 201: ExternalSharedExternalSharedModel; }; export type PostExternalMixedResponse = PostExternalMixedResponses[keyof PostExternalMixedResponses]; @@ -372,13 +388,13 @@ export type GetExternalArrayResponses = { /** * Response with array of external models */ - 200: Array<2>; + 200: Array; }; export type GetExternalArrayResponse = GetExternalArrayResponses[keyof GetExternalArrayResponses]; export type PostExternalArrayData = { - body: Array<2>; + body: Array; path?: never; query?: never; url: '/external-array'; @@ -388,7 +404,7 @@ export type PostExternalArrayResponses = { /** * Response with array of external models */ - 201: Array<2>; + 201: Array; }; export type PostExternalArrayResponse = PostExternalArrayResponses[keyof PostExternalArrayResponses]; @@ -404,13 +420,13 @@ export type GetExternalUnionResponses = { /** * Response with union of external types */ - 200: 2 | 3 | 7; + 200: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; }; export type GetExternalUnionResponse = GetExternalUnionResponses[keyof GetExternalUnionResponses]; export type PostExternalUnionData = { - body: 2 | 3 | 7; + body: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; path?: never; query?: never; url: '/external-union'; @@ -420,7 +436,7 @@ export type PostExternalUnionResponses = { /** * Response with union of external types */ - 201: 2 | 3 | 7; + 201: ExternalSharedExternalSharedModel | ExternalSharedExternalSharedModelWithUuid | ExternalSharedExternalNested; }; export type PostExternalUnionResponse = PostExternalUnionResponses[keyof PostExternalUnionResponses]; @@ -428,24 +444,24 @@ export type PostExternalUnionResponse = PostExternalUnionResponses[keyof PostExt export type GetExternalPropertiesByIdData = { body?: never; headers?: { - deep?: 5; + deep?: ExternalSharedDeep; }; path: { - id: 4; + id: ExternalSharedId; }; query?: { - uuid?: 3; + uuid?: ExternalSharedExternalSharedModelWithUuid; }; url: '/external-properties/{id}'; }; export type GetExternalPropertiesByIdResponses = { 200: { - id?: 4; - name?: 9; - uuid?: 3; - deep?: 5; - numeric?: 6; + id?: ExternalSharedId; + name?: ExternalSharedName; + uuid?: ExternalSharedExternalSharedModelWithUuid; + deep?: ExternalSharedDeep; + numeric?: ExternalShared1; }; }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts new file mode 100644 index 000000000..89c7c12b3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts @@ -0,0 +1,607 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpRequest } from '@angular/common/http'; +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, CollectionFormatData, TypesData, UploadFileData, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { client } from '../../../client.gen'; +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultRequests { + public export(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public patchApiVbyApiVersionNoTag(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public import(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public fooWow(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/no+tag', + ...options + }); + } + + public getApiVbyApiVersionSimpleOperation(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple:operation', + ...options + }); + } +} + +class ODataControllerRequests { + public apiVVersionODataControllerCount(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple/$count', + ...options + }); + } +} + +class VVersionRequests { + oDataController = new ODataControllerRequests(); +} + +class ApiRequests { + vVersion = new VVersionRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleRequests { + public deleteCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public getCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public headCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'HEAD', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public optionsCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public patchCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public postCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/simple', + ...options + }); + } + + public putCallWithoutParametersAndResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/simple', + ...options + }); + } + api = new ApiRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersRequests { + public deleteFoo(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); + } + + public callWithParameters(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); + } + + public callWithWeirdParameterNames(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); + } + + public getCallWithOptionalParam(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/parameters', + ...options + }); + } + + public postCallWithOptionalParam(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsRequests { + public callWithDescriptions(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/descriptions', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DeprecatedRequests { + /** + * @deprecated + */ + public deprecatedCall(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class RequestBodyRequests { + public postApiVbyApiVersionRequestBody(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/requestBody', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FormDataRequests { + public postApiVbyApiVersionFormData(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/formData', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsRequests { + public callWithDefaultParameters(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/defaults', + ...options + }); + } + + public callWithDefaultOptionalParameters(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/defaults', + ...options + }); + } + + public callToTestOrderOfParams(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/defaults', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateRequests { + public duplicateName(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName2(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName3(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/duplicate', + ...options + }); + } + + public duplicateName4(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/duplicate', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentRequests { + public callWithNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no-content', + ...options + }); + } + + public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseRequests { + public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); + } + + public callWithResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/response', + ...options + }); + } + + public callWithDuplicateResponses(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/response', + ...options + }); + } + + public callWithResponses(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/response', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1Requests { + public dummyA(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); + } + + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2Requests { + public dummyA(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); + } + + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3Requests { + public dummyB(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatRequests { + public collectionFormat(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesRequests { + public types(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/types', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class UploadRequests { + public uploadFile(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/upload', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FileResponseRequests { + public fileResponse(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/file/{id}', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexRequests { + public complexTypes(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/complex', + ...options + }); + } + + public complexParams(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/complex/{id}', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipartRequests { + public multipartResponse(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multipart', + ...options + }); + } + + public multipartRequest(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/multipart', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderRequests { + public callWithResultFromHeader(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/header', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorRequests { + public testErrorCode(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/error', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊRequests { + public nonAsciiæøåÆøÅöôêÊ字符串(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); + } + + /** + * Login User + */ + public putWithFormUrlEncoded(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts new file mode 100644 index 000000000..c4b0e6215 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts @@ -0,0 +1,503 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { httpResource } from '@angular/common/http'; +import { DefaultRequests, SimpleRequests, ParametersRequests, DescriptionsRequests, DeprecatedRequests, RequestBodyRequests, FormDataRequests, DefaultsRequests, DuplicateRequests, NoContentRequests, ResponseRequests, MultipleTags1Requests, CollectionFormatRequests, TypesRequests, UploadRequests, FileResponseRequests, ComplexRequests, MultipartRequests, HeaderRequests, ErrorRequests, NonAsciiÆøåÆøÅöôêÊRequests } from './requests.gen'; +import { inject, Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultResources { + public export(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).export(opts) : undefined; + }); + } + + public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + }); + } + + public import(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).import(opts) : undefined; + }); + } + + public fooWow(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).fooWow(opts) : undefined; + }); + } + + public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; + }); + } +} + +class ODataControllerResources { + public apiVVersionODataControllerCount(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).api.vVersion.oDataController.apiVVersionODataControllerCount(opts) : undefined; + }); + } +} + +class VVersionResources { + oDataController = new ODataControllerResources(); +} + +class ApiResources { + vVersion = new VVersionResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleResources { + public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).getCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).headCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).postCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleRequests).putCallWithoutParametersAndResponse(opts) : undefined; + }); + } + api = new ApiResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersResources { + public deleteFoo(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).deleteFoo(opts) : undefined; + }); + } + + public callWithParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).callWithParameters(opts) : undefined; + }); + } + + public callWithWeirdParameterNames(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).callWithWeirdParameterNames(opts) : undefined; + }); + } + + public getCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).getCallWithOptionalParam(opts) : undefined; + }); + } + + public postCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersRequests).postCallWithOptionalParam(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsResources { + public callWithDescriptions(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DescriptionsRequests).callWithDescriptions(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DeprecatedResources { + /** + * @deprecated + */ + public deprecatedCall(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DeprecatedRequests).deprecatedCall(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class RequestBodyResources { + public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(RequestBodyRequests).postApiVbyApiVersionRequestBody(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FormDataResources { + public postApiVbyApiVersionFormData(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FormDataRequests).postApiVbyApiVersionFormData(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsResources { + public callWithDefaultParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callWithDefaultParameters(opts) : undefined; + }); + } + + public callWithDefaultOptionalParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callWithDefaultOptionalParameters(opts) : undefined; + }); + } + + public callToTestOrderOfParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsRequests).callToTestOrderOfParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateResources { + public duplicateName(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName(opts) : undefined; + }); + } + + public duplicateName2(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName2(opts) : undefined; + }); + } + + public duplicateName3(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName3(opts) : undefined; + }); + } + + public duplicateName4(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateRequests).duplicateName4(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentResources { + public callWithNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NoContentRequests).callWithNoContentResponse(opts) : undefined; + }); + } + + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseResources { + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } + + public callWithResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponse(opts) : undefined; + }); + } + + public callWithDuplicateResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithDuplicateResponses(opts) : undefined; + }); + } + + public callWithResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseRequests).callWithResponses(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1Resources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2Resources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3Resources { + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatResources { + public collectionFormat(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(CollectionFormatRequests).collectionFormat(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesResources { + public types(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(TypesRequests).types(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class UploadResources { + public uploadFile(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(UploadRequests).uploadFile(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FileResponseResources { + public fileResponse(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FileResponseRequests).fileResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexResources { + public complexTypes(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexRequests).complexTypes(opts) : undefined; + }); + } + + public complexParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexRequests).complexParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipartResources { + public multipartResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartRequests).multipartResponse(opts) : undefined; + }); + } + + public multipartRequest(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartRequests).multipartRequest(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderResources { + public callWithResultFromHeader(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(HeaderRequests).callWithResultFromHeader(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorResources { + public testErrorCode(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ErrorRequests).testErrorCode(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊResources { + public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + }); + } + + /** + * Login User + */ + public putWithFormUrlEncoded(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).putWithFormUrlEncoded(opts) : undefined; + }); + } +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts new file mode 100644 index 000000000..2e5fe1c9b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config2) => Config2 & T>; + +export const client = createClient2(createConfig2({ + baseUrl: 'http://localhost:3000/base' +})); + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig2 = (override?: Config) => Config & T>; + +export const client2 = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts new file mode 100644 index 000000000..40c2b65df --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -0,0 +1,261 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpResponse } from '@angular/common/http'; +import { + HttpClient, + HttpErrorResponse, + HttpEventType, + HttpRequest, +} from '@angular/common/http'; +import { + assertInInjectionContext, + inject, + provideAppInitializer, + runInInjectionContext, +} from '@angular/core'; +import { firstValueFrom } from 'rxjs'; +import { filter } from 'rxjs/operators'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, + ResponseStyle, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export function provideHeyApiClient(client: Client) { + return provideAppInitializer(() => { + const httpClient = inject(HttpClient); + client.setConfig({ httpClient }); + }); +} + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >(); + + const requestOptions = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + options: RequestOptions, + ) => { + const opts = { + ..._config, + ...options, + headers: mergeHeaders(_config.headers, options.headers), + httpClient: options.httpClient ?? _config.httpClient, + serializedBody: undefined, + }; + + if (!opts.httpClient) { + if (opts.injector) { + opts.httpClient = runInInjectionContext(opts.injector, () => + inject(HttpClient), + ); + } else { + assertInInjectionContext(requestOptions); + opts.httpClient = inject(HttpClient); + } + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts as any); + + const req = new HttpRequest( + opts.method ?? 'GET', + url, + getValidRequestBody(opts), + { + redirect: 'follow', + ...opts, + }, + ); + + return { opts, req, url }; + }; + + const beforeRequest = async (options: RequestOptions) => { + const { opts, req, url } = requestOptions(options); + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + return { opts, req, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, req: initialReq } = await beforeRequest(options); + + let req = initialReq; + + for (const fn of interceptors.request._fns) { + if (fn) { + req = await fn(req, opts as any); + } + } + + const result: { + request: HttpRequest; + response: any; + } = { + request: req, + response: null, + }; + + try { + result.response = (await firstValueFrom( + opts + .httpClient!.request(req) + .pipe(filter((event) => event.type === HttpEventType.Response)), + )) as HttpResponse; + + for (const fn of interceptors.response._fns) { + if (fn) { + result.response = await fn(result.response, req, opts as any); + } + } + + let bodyResponse = result.response.body; + + if (opts.responseValidator) { + await opts.responseValidator(bodyResponse); + } + + if (opts.responseTransformer) { + bodyResponse = await opts.responseTransformer(bodyResponse); + } + + return opts.responseStyle === 'data' + ? bodyResponse + : { data: bodyResponse, ...result }; + } catch (error) { + if (error instanceof HttpErrorResponse) { + result.response = error; + } + + let finalError = error instanceof HttpErrorResponse ? error.error : error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn( + finalError, + result.response as any, + req, + opts as any, + )) as string; + } + } + + if (opts.throwOnError) { + throw finalError; + } + + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + requestOptions: (options) => { + if (options.security) { + throw new Error('Security is not supported in requestOptions'); + } + + if (options.requestValidator) { + throw new Error( + 'Request validation is not supported in requestOptions', + ); + } + + return requestOptions(options).req; + }, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..6cdf8ad48 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/types.gen.ts @@ -0,0 +1,283 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + HttpClient, + HttpErrorResponse, + HttpHeaders, + HttpRequest, + HttpResponse, +} from '@angular/common/http'; +import type { Injector } from '@angular/core'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `HttpHeaders` object with. + * + * {@link https://angular.dev/api/common/http/HttpHeaders#constructor See more} + */ + headers?: + | HttpHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The HTTP client to use for making requests. + */ + httpClient?: HttpClient; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + /** + * Optional custom injector for dependency resolution if you don't implicitly or explicitly provide one. + */ + injector?: Injector; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = Promise< + ThrowOnError extends true + ? TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: HttpRequest; + response: HttpResponse; + } + : TResponseStyle extends 'data' + ? + | (TData extends Record ? TData[keyof TData] : TData) + | undefined + : + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + request: HttpRequest; + response: HttpResponse; + } + | { + data: undefined; + error: TError[keyof TError]; + request: HttpRequest; + response: HttpErrorResponse & { + error: TError[keyof TError] | null; + }; + } +>; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type RequestOptionsFn = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: RequestOptions, +) => HttpRequest; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >; + requestOptions: RequestOptionsFn; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts new file mode 100644 index 000000000..3bb799dff --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts @@ -0,0 +1,431 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { HttpHeaders } from '@angular/common/http'; + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +export const setAuthParams = async ( + options: Pick, 'security'> & + Pick & { + headers: HttpHeaders; + }, +) => { + for (const auth of options.security) { + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers = options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers = options.headers.set(name, token); + break; + } + + return; + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): HttpHeaders => { + let mergedHeaders = new HttpHeaders(); + + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + if (header instanceof HttpHeaders) { + // Merge HttpHeaders instance + header.keys().forEach((key) => { + const values = header.getAll(key); + if (values) { + values.forEach((value) => { + mergedHeaders = mergedHeaders.append(key, value); + }); + } + }); + } else { + // Merge plain object headers + for (const [key, value] of Object.entries(header)) { + if (value === null) { + mergedHeaders = mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders = mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders = mergedHeaders.set( + key, + typeof value === 'object' + ? JSON.stringify(value) + : (value as string), + ); + } + } + } + } + + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/sdk.gen.ts new file mode 100644 index 000000000..17622c66b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/types.gen.ts new file mode 100644 index 000000000..4c755476d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts new file mode 100644 index 000000000..e7b3678ca --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts @@ -0,0 +1,444 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpRequest } from '@angular/common/http'; +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, CollectionFormatData, TypesData, UploadFileData, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { client } from '../../../client.gen'; + +export const exportRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTagRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const importRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const fooWowRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCountRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperationRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'HEAD', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'OPTIONS', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PATCH', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFooRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptionsRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCallRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParametersRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options + }); +}; + +export const callWithWeirdParameterNamesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options + }); +}; + +export const getCallWithOptionalParamRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/parameters', + ...options + }); +}; + +export const postCallWithOptionalParamRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/parameters', + ...options + }); +}; + +export const postApiVbyApiVersionRequestBodyRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/requestBody', + ...options + }); +}; + +export const postApiVbyApiVersionFormDataRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/formData', + ...options + }); +}; + +export const callWithDefaultParametersRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParametersRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParamsRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateNameRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'DELETE', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4Request = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyARequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyBRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponsesRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponsesRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormatRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const typesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFileRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/upload', + ...options + }); +}; + +export const fileResponseRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypesRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponseRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequestRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const complexParamsRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/complex/{id}', + ...options + }); +}; + +export const callWithResultFromHeaderRequest = (options?: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCodeRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串Request = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncodedRequest = (options: Options): HttpRequest => { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'PUT', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts new file mode 100644 index 000000000..a6d4fdd5b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts @@ -0,0 +1,348 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options } from '../../../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../../types.gen'; +import { httpResource } from '@angular/common/http'; +import { exportRequest, patchApiVbyApiVersionNoTagRequest, importRequest, fooWowRequest, apiVVersionODataControllerCountRequest, getApiVbyApiVersionSimpleOperationRequest, deleteCallWithoutParametersAndResponseRequest, getCallWithoutParametersAndResponseRequest, headCallWithoutParametersAndResponseRequest, optionsCallWithoutParametersAndResponseRequest, patchCallWithoutParametersAndResponseRequest, postCallWithoutParametersAndResponseRequest, putCallWithoutParametersAndResponseRequest, deleteFooRequest, callWithDescriptionsRequest, deprecatedCallRequest, callWithParametersRequest, callWithWeirdParameterNamesRequest, getCallWithOptionalParamRequest, postCallWithOptionalParamRequest, postApiVbyApiVersionRequestBodyRequest, postApiVbyApiVersionFormDataRequest, callWithDefaultParametersRequest, callWithDefaultOptionalParametersRequest, callToTestOrderOfParamsRequest, duplicateNameRequest, duplicateName2Request, duplicateName3Request, duplicateName4Request, callWithNoContentResponseRequest, callWithResponseAndNoContentResponseRequest, dummyARequest, dummyBRequest, callWithResponseRequest, callWithDuplicateResponsesRequest, callWithResponsesRequest, collectionFormatRequest, typesRequest, uploadFileRequest, fileResponseRequest, complexTypesRequest, multipartResponseRequest, multipartRequestRequest, complexParamsRequest, callWithResultFromHeaderRequest, testErrorCodeRequest, nonAsciiæøåÆøÅöôêÊ字符串Request, putWithFormUrlEncodedRequest } from './requests.gen'; + +export const exportResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? exportRequest(opts) : undefined; + }); +}; + +export const patchApiVbyApiVersionNoTagResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? patchApiVbyApiVersionNoTagRequest(opts) : undefined; + }); +}; + +export const importResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? importRequest(opts) : undefined; + }); +}; + +export const fooWowResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? fooWowRequest(opts) : undefined; + }); +}; + +export const apiVVersionODataControllerCountResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? apiVVersionODataControllerCountRequest(opts) : undefined; + }); +}; + +export const getApiVbyApiVersionSimpleOperationResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? getApiVbyApiVersionSimpleOperationRequest(opts) : undefined; + }); +}; + +export const deleteCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? deleteCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const getCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? getCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const headCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? headCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const optionsCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? optionsCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const patchCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? patchCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const postCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const putCallWithoutParametersAndResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? putCallWithoutParametersAndResponseRequest(opts) : undefined; + }); +}; + +export const deleteFooResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? deleteFooRequest(opts) : undefined; + }); +}; + +export const callWithDescriptionsResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDescriptionsRequest(opts) : undefined; + }); +}; + +/** + * @deprecated + */ +export const deprecatedCallResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? deprecatedCallRequest(opts) : undefined; + }); +}; + +export const callWithParametersResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithParametersRequest(opts) : undefined; + }); +}; + +export const callWithWeirdParameterNamesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithWeirdParameterNamesRequest(opts) : undefined; + }); +}; + +export const getCallWithOptionalParamResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? getCallWithOptionalParamRequest(opts) : undefined; + }); +}; + +export const postCallWithOptionalParamResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postCallWithOptionalParamRequest(opts) : undefined; + }); +}; + +export const postApiVbyApiVersionRequestBodyResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postApiVbyApiVersionRequestBodyRequest(opts) : undefined; + }); +}; + +export const postApiVbyApiVersionFormDataResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? postApiVbyApiVersionFormDataRequest(opts) : undefined; + }); +}; + +export const callWithDefaultParametersResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDefaultParametersRequest(opts) : undefined; + }); +}; + +export const callWithDefaultOptionalParametersResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDefaultOptionalParametersRequest(opts) : undefined; + }); +}; + +export const callToTestOrderOfParamsResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callToTestOrderOfParamsRequest(opts) : undefined; + }); +}; + +export const duplicateNameResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateNameRequest(opts) : undefined; + }); +}; + +export const duplicateName2Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName2Request(opts) : undefined; + }); +}; + +export const duplicateName3Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName3Request(opts) : undefined; + }); +}; + +export const duplicateName4Resource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? duplicateName4Request(opts) : undefined; + }); +}; + +export const callWithNoContentResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithNoContentResponseRequest(opts) : undefined; + }); +}; + +export const callWithResponseAndNoContentResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponseAndNoContentResponseRequest(opts) : undefined; + }); +}; + +export const dummyAResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? dummyARequest(opts) : undefined; + }); +}; + +export const dummyBResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? dummyBRequest(opts) : undefined; + }); +}; + +export const callWithResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponseRequest(opts) : undefined; + }); +}; + +export const callWithDuplicateResponsesResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithDuplicateResponsesRequest(opts) : undefined; + }); +}; + +export const callWithResponsesResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResponsesRequest(opts) : undefined; + }); +}; + +export const collectionFormatResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? collectionFormatRequest(opts) : undefined; + }); +}; + +export const typesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? typesRequest(opts) : undefined; + }); +}; + +export const uploadFileResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? uploadFileRequest(opts) : undefined; + }); +}; + +export const fileResponseResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? fileResponseRequest(opts) : undefined; + }); +}; + +export const complexTypesResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? complexTypesRequest(opts) : undefined; + }); +}; + +export const multipartResponseResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? multipartResponseRequest(opts) : undefined; + }); +}; + +export const multipartRequestResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? multipartRequestRequest(opts) : undefined; + }); +}; + +export const complexParamsResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? complexParamsRequest(opts) : undefined; + }); +}; + +export const callWithResultFromHeaderResource = (options?: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? callWithResultFromHeaderRequest(opts) : undefined; + }); +}; + +export const testErrorCodeResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? testErrorCodeRequest(opts) : undefined; + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串Resource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? nonAsciiæøåÆøÅöôêÊ字符串Request(opts) : undefined; + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncodedResource = (options: () => Options | undefined) => { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? putWithFormUrlEncodedRequest(opts) : undefined; + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts new file mode 100644 index 000000000..2e5fe1c9b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts @@ -0,0 +1,32 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config2) => Config2 & T>; + +export const client = createClient2(createConfig2({ + baseUrl: 'http://localhost:3000/base' +})); + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig2 = (override?: Config) => Config & T>; + +export const client2 = createClient(createConfig({ + baseUrl: 'http://localhost:3000/base' +})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts new file mode 100644 index 000000000..40c2b65df --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts @@ -0,0 +1,261 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { HttpResponse } from '@angular/common/http'; +import { + HttpClient, + HttpErrorResponse, + HttpEventType, + HttpRequest, +} from '@angular/common/http'; +import { + assertInInjectionContext, + inject, + provideAppInitializer, + runInInjectionContext, +} from '@angular/core'; +import { firstValueFrom } from 'rxjs'; +import { filter } from 'rxjs/operators'; + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, + ResponseStyle, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +export function provideHeyApiClient(client: Client) { + return provideAppInitializer(() => { + const httpClient = inject(HttpClient); + client.setConfig({ httpClient }); + }); +} + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >(); + + const requestOptions = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + options: RequestOptions, + ) => { + const opts = { + ..._config, + ...options, + headers: mergeHeaders(_config.headers, options.headers), + httpClient: options.httpClient ?? _config.httpClient, + serializedBody: undefined, + }; + + if (!opts.httpClient) { + if (opts.injector) { + opts.httpClient = runInInjectionContext(opts.injector, () => + inject(HttpClient), + ); + } else { + assertInInjectionContext(requestOptions); + opts.httpClient = inject(HttpClient); + } + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts as any); + + const req = new HttpRequest( + opts.method ?? 'GET', + url, + getValidRequestBody(opts), + { + redirect: 'follow', + ...opts, + }, + ); + + return { opts, req, url }; + }; + + const beforeRequest = async (options: RequestOptions) => { + const { opts, req, url } = requestOptions(options); + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + return { opts, req, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, req: initialReq } = await beforeRequest(options); + + let req = initialReq; + + for (const fn of interceptors.request._fns) { + if (fn) { + req = await fn(req, opts as any); + } + } + + const result: { + request: HttpRequest; + response: any; + } = { + request: req, + response: null, + }; + + try { + result.response = (await firstValueFrom( + opts + .httpClient!.request(req) + .pipe(filter((event) => event.type === HttpEventType.Response)), + )) as HttpResponse; + + for (const fn of interceptors.response._fns) { + if (fn) { + result.response = await fn(result.response, req, opts as any); + } + } + + let bodyResponse = result.response.body; + + if (opts.responseValidator) { + await opts.responseValidator(bodyResponse); + } + + if (opts.responseTransformer) { + bodyResponse = await opts.responseTransformer(bodyResponse); + } + + return opts.responseStyle === 'data' + ? bodyResponse + : { data: bodyResponse, ...result }; + } catch (error) { + if (error instanceof HttpErrorResponse) { + result.response = error; + } + + let finalError = error instanceof HttpErrorResponse ? error.error : error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn( + finalError, + result.response as any, + req, + opts as any, + )) as string; + } + } + + if (opts.throwOnError) { + throw finalError; + } + + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + } + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + requestOptions: (options) => { + if (options.security) { + throw new Error('Security is not supported in requestOptions'); + } + + if (options.requestValidator) { + throw new Error( + 'Request validation is not supported in requestOptions', + ); + } + + return requestOptions(options).req; + }, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..6cdf8ad48 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/types.gen.ts @@ -0,0 +1,283 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + HttpClient, + HttpErrorResponse, + HttpHeaders, + HttpRequest, + HttpResponse, +} from '@angular/common/http'; +import type { Injector } from '@angular/core'; + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + Omit { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `HttpHeaders` object with. + * + * {@link https://angular.dev/api/common/http/HttpHeaders#constructor See more} + */ + headers?: + | HttpHeaders + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The HTTP client to use for making requests. + */ + httpClient?: HttpClient; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + /** + * Optional custom injector for dependency resolution if you don't implicitly or explicitly provide one. + */ + injector?: Injector; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = Promise< + ThrowOnError extends true + ? TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: HttpRequest; + response: HttpResponse; + } + : TResponseStyle extends 'data' + ? + | (TData extends Record ? TData[keyof TData] : TData) + | undefined + : + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + request: HttpRequest; + response: HttpResponse; + } + | { + data: undefined; + error: TError[keyof TError]; + request: HttpRequest; + response: HttpErrorResponse & { + error: TError[keyof TError] | null; + }; + } +>; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type RequestOptionsFn = < + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: RequestOptions, +) => HttpRequest; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware< + HttpRequest, + HttpResponse, + unknown, + ResolvedRequestOptions + >; + requestOptions: RequestOptionsFn; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts new file mode 100644 index 000000000..3bb799dff --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts @@ -0,0 +1,431 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { HttpHeaders } from '@angular/common/http'; + +import { getAuthToken } from '../core/auth.gen'; +import type { + QuerySerializer, + QuerySerializerOptions, +} from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +interface PathSerializer { + path: Record; + url: string; +} + +const PATH_PARAM_RE = /\{[^{}]+\}/g; + +type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +type ArraySeparatorStyle = ArrayStyle | MatrixStyle; + +const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): 'blob' | 'formData' | 'json' | 'stream' | 'text' | undefined => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +export const setAuthParams = async ( + options: Pick, 'security'> & + Pick & { + headers: HttpHeaders; + }, +) => { + for (const auth of options.security) { + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers = options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers = options.headers.set(name, token); + break; + } + + return; + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => { + const url = getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): HttpHeaders => { + let mergedHeaders = new HttpHeaders(); + + for (const header of headers) { + if (!header || typeof header !== 'object') { + continue; + } + + if (header instanceof HttpHeaders) { + // Merge HttpHeaders instance + header.keys().forEach((key) => { + const values = header.getAll(key); + if (values) { + values.forEach((value) => { + mergedHeaders = mergedHeaders.append(key, value); + }); + } + }); + } else { + // Merge plain object headers + for (const [key, value] of Object.entries(header)) { + if (value === null) { + mergedHeaders = mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders = mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders = mergedHeaders.set( + key, + typeof value === 'object' + ? JSON.stringify(value) + : (value as string), + ); + } + } + } + } + + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + headers: defaultHeaders, + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/sdk.gen.ts new file mode 100644 index 000000000..17622c66b --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/sdk.gen.ts @@ -0,0 +1,409 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, PatchApiVbyApiVersionNoTagResponses, ImportData, ImportResponses, FooWowData, FooWowResponses, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponses, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponses, GetApiVbyApiVersionSimpleOperationErrors, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponses, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponses, DummyAData, DummyAResponses, DummyBData, DummyBResponses, CallWithResponseData, CallWithResponseResponses, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponses, CallWithDuplicateResponsesErrors, CallWithResponsesData, CallWithResponsesResponses, CallWithResponsesErrors, CollectionFormatData, TypesData, TypesResponses, UploadFileData, UploadFileResponses, FileResponseData, FileResponseResponses, ComplexTypesData, ComplexTypesResponses, ComplexTypesErrors, MultipartResponseData, MultipartResponseResponses, MultipartRequestData, ComplexParamsData, ComplexParamsResponses, CallWithResultFromHeaderData, CallWithResultFromHeaderResponses, CallWithResultFromHeaderErrors, TestErrorCodeData, TestErrorCodeResponses, TestErrorCodeErrors, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PutWithFormUrlEncodedData } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +export const export_ = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const patchApiVbyApiVersionNoTag = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const import_ = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/no+tag', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const fooWow = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/no+tag', + ...options + }); +}; + +export const apiVVersionODataControllerCount = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple/$count', + ...options + }); +}; + +export const getApiVbyApiVersionSimpleOperation = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/simple:operation', + ...options + }); +}; + +export const deleteCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const getCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const headCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).head({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const optionsCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).options({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const patchCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).patch({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const postCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const putCallWithoutParametersAndResponse = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/simple', + ...options + }); +}; + +export const deleteFoo = (options: Options) => { + return (options.client ?? client).delete({ + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', + ...options + }); +}; + +export const callWithDescriptions = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/descriptions', + ...options + }); +}; + +/** + * @deprecated + */ +export const deprecatedCall = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/deprecated', + ...options + }); +}; + +export const callWithParameters = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameterPath}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const callWithWeirdParameterNames = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const getCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postCallWithOptionalParam = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/parameters', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options.headers + } + }); +}; + +export const postApiVbyApiVersionRequestBody = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/requestBody', + ...options, + headers: { + 'Content-Type': 'application/json', + ...options?.headers + } + }); +}; + +export const postApiVbyApiVersionFormData = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/formData', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const callWithDefaultParameters = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callWithDefaultOptionalParameters = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const callToTestOrderOfParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/defaults', + ...options + }); +}; + +export const duplicateName = (options?: Options) => { + return (options?.client ?? client).delete({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName2 = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName3 = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const duplicateName4 = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/duplicate', + ...options + }); +}; + +export const callWithNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/no-content', + ...options + }); +}; + +export const callWithResponseAndNoContentResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/response-and-no-content', + ...options + }); +}; + +export const dummyA = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/a', + ...options + }); +}; + +export const dummyB = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multiple-tags/b', + ...options + }); +}; + +export const callWithResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithDuplicateResponses = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const callWithResponses = (options?: Options) => { + return (options?.client ?? client).put({ + url: '/api/v{api-version}/response', + ...options + }); +}; + +export const collectionFormat = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/collectionFormat', + ...options + }); +}; + +export const types = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/types', + ...options + }); +}; + +export const uploadFile = (options: Options) => { + return (options.client ?? client).post({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/upload', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; + +export const fileResponse = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/file/{id}', + ...options + }); +}; + +export const complexTypes = (options: Options) => { + return (options.client ?? client).get({ + url: '/api/v{api-version}/complex', + ...options + }); +}; + +export const multipartResponse = (options?: Options) => { + return (options?.client ?? client).get({ + url: '/api/v{api-version}/multipart', + ...options + }); +}; + +export const multipartRequest = (options?: Options) => { + return (options?.client ?? client).post({ + ...formDataBodySerializer, + url: '/api/v{api-version}/multipart', + ...options, + headers: { + 'Content-Type': null, + ...options?.headers + } + }); +}; + +export const complexParams = (options: Options) => { + return (options.client ?? client).put({ + url: '/api/v{api-version}/complex/{id}', + ...options, + headers: { + 'Content-Type': 'application/json-patch+json', + ...options.headers + } + }); +}; + +export const callWithResultFromHeader = (options?: Options) => { + return (options?.client ?? client).post({ + url: '/api/v{api-version}/header', + ...options + }); +}; + +export const testErrorCode = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/error', + ...options + }); +}; + +export const nonAsciiæøåÆøÅöôêÊ字符串 = (options: Options) => { + return (options.client ?? client).post({ + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); +}; + +/** + * Login User + */ +export const putWithFormUrlEncoded = (options: Options) => { + return (options.client ?? client).put({ + ...urlSearchParamsBodySerializer, + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + ...options.headers + } + }); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/types.gen.ts new file mode 100644 index 000000000..4c755476d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/types.gen.ts @@ -0,0 +1,2065 @@ +// This file is auto-generated by @hey-api/openapi-ts + +/** + * Model with number-only name + */ +export type _400 = string; + +/** + * External ref to shared model (A) + */ +export type ExternalRefA = ExternalSharedExternalSharedModel; + +/** + * External ref to shared model (B) + */ +export type ExternalRefB = ExternalSharedExternalSharedModel; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CamelCaseCommentWithBreaks = number; + +/** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ +export type CommentWithBreaks = number; + +/** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ +export type CommentWithBackticks = number; + +/** + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work + */ +export type CommentWithBackticksAndQuotes = number; + +/** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ +export type CommentWithSlashes = number; + +/** + * Testing expression placeholders in string: ${expression} should work + */ +export type CommentWithExpressionPlaceholders = number; + +/** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ +export type CommentWithQuotes = number; + +/** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ +export type CommentWithReservedCharacters = number; + +/** + * This is a simple number + */ +export type SimpleInteger = number; + +/** + * This is a simple boolean + */ +export type SimpleBoolean = boolean; + +/** + * This is a simple string + */ +export type SimpleString = string; + +/** + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) + */ +export type NonAsciiStringæøåÆøÅöôêÊ字符串 = string; + +/** + * This is a simple file + */ +export type SimpleFile = Blob | File; + +/** + * This is a simple reference + */ +export type SimpleReference = ModelWithString; + +/** + * This is a simple string + */ +export type SimpleStringWithPattern = string | null; + +/** + * This is a simple enum with strings + */ +export type EnumWithStrings = 'Success' | 'Warning' | 'Error' | "'Single Quote'" | '"Double Quotes"' | 'Non-ascii: øæåôöØÆÅÔÖ字符串'; + +export type EnumWithReplacedCharacters = "'Single Quote'" | '"Double Quotes"' | 'øæåôöØÆÅÔÖ字符串' | 3.1 | ''; + +/** + * This is a simple enum with numbers + */ +export type EnumWithNumbers = 1 | 2 | 3 | 1.1 | 1.2 | 1.3 | 100 | 200 | 300 | -100 | -200 | -300 | -1.1 | -1.2 | -1.3; + +/** + * Success=1,Warning=2,Error=3 + */ +export type EnumFromDescription = number; + +/** + * This is a simple enum with numbers + */ +export type EnumWithExtensions = 200 | 400 | 500; + +export type EnumWithXEnumNames = 0 | 1 | 2; + +/** + * This is a simple array with numbers + */ +export type ArrayWithNumbers = Array; + +/** + * This is a simple array with booleans + */ +export type ArrayWithBooleans = Array; + +/** + * This is a simple array with strings + */ +export type ArrayWithStrings = Array; + +/** + * This is a simple array with references + */ +export type ArrayWithReferences = Array; + +/** + * This is a simple array containing an array + */ +export type ArrayWithArray = Array>; + +/** + * This is a simple array with properties + */ +export type ArrayWithProperties = Array<{ + '16x16'?: CamelCaseCommentWithBreaks; + bar?: string; +}>; + +/** + * This is a simple array with any of properties + */ +export type ArrayWithAnyOfProperties = Array<{ + foo?: string; +} | { + bar?: string; +}>; + +export type AnyOfAnyAndNull = { + data?: unknown | null; +}; + +/** + * This is a simple array with any of properties + */ +export type AnyOfArrays = { + results?: Array<{ + foo?: string; + } | { + bar?: string; + }>; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithString = { + [key: string]: string; +}; + +export type DictionaryWithPropertiesAndAdditionalProperties = { + foo?: number; + bar?: boolean; + [key: string]: string | number | boolean | undefined; +}; + +/** + * This is a string reference + */ +export type DictionaryWithReference = { + [key: string]: ModelWithString; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithArray = { + [key: string]: Array; +}; + +/** + * This is a string dictionary + */ +export type DictionaryWithDictionary = { + [key: string]: { + [key: string]: string; + }; +}; + +/** + * This is a complex dictionary + */ +export type DictionaryWithProperties = { + [key: string]: { + foo?: string; + bar?: string; + }; +}; + +/** + * This is a model with one number property + */ +export type ModelWithInteger = { + /** + * This is a simple number property + */ + prop?: number; +}; + +/** + * This is a model with one boolean property + */ +export type ModelWithBoolean = { + /** + * This is a simple boolean property + */ + prop?: boolean; +}; + +/** + * This is a model with one string property + */ +export type ModelWithString = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * This is a model with one string property + */ +export type ModelWithStringError = { + /** + * This is a simple string property + */ + prop?: string; +}; + +/** + * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) + */ +export type ModelFromZendesk = string; + +/** + * This is a model with one string property + */ +export type ModelWithNullableString = { + /** + * This is a simple string property + */ + nullableProp1?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp1: string | null; + /** + * This is a simple string property + */ + nullableProp2?: string | null; + /** + * This is a simple string property + */ + nullableRequiredProp2: string | null; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnum = { + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; + /** + * These are the HTTP error code enums + */ + statusCode?: '100' | '200 FOO' | '300 FOO_BAR' | '400 foo-bar' | '500 foo.bar' | '600 foo&bar'; + /** + * Simple boolean enum + */ + bool?: true; +}; + +/** + * This is a model with one enum with escaped name + */ +export type ModelWithEnumWithHyphen = { + /** + * Foo-Bar-Baz-Qux + */ + 'foo-bar-baz-qux'?: '3.0'; +}; + +/** + * This is a model with one enum + */ +export type ModelWithEnumFromDescription = { + /** + * Success=1,Warning=2,Error=3 + */ + test?: number; +}; + +/** + * This is a model with nested enums + */ +export type ModelWithNestedEnums = { + dictionaryWithEnum?: { + [key: string]: 'Success' | 'Warning' | 'Error'; + }; + dictionaryWithEnumFromDescription?: { + [key: string]: number; + }; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; + /** + * This is a simple enum with strings + */ + 'foo_bar-enum'?: 'Success' | 'Warning' | 'Error' | 'ØÆÅ字符串'; +}; + +/** + * This is a model with one property containing a reference + */ +export type ModelWithReference = { + prop?: ModelWithProperties; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArrayReadOnlyAndWriteOnly = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing an array + */ +export type ModelWithArray = { + prop?: Array; + propWithFile?: Array; + propWithNumber?: Array; +}; + +/** + * This is a model with one property containing a dictionary + */ +export type ModelWithDictionary = { + prop?: { + [key: string]: string; + }; +}; + +/** + * This is a deprecated model with a deprecated property + * @deprecated + */ +export type DeprecatedModel = { + /** + * This is a deprecated property + * @deprecated + */ + prop?: string; +}; + +/** + * This is a model with one property containing a circular reference + */ +export type ModelWithCircularReference = { + prop?: ModelWithCircularReference; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * Circle + */ +export type ModelCircle = { + kind: string; + radius?: number; +}; + +/** + * Square + */ +export type ModelSquare = { + kind: string; + sideLength?: number; +}; + +/** + * This is a model with one property with a 'one of' relationship where the options are not $ref + */ +export type CompositionWithOneOfDiscriminator = ({ + kind: 'circle'; +} & ModelCircle) | ({ + kind: 'square'; +} & ModelSquare); + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOf = { + propA?: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; +}; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithAnyOfAnonymous = { + propA?: { + propA?: string; + } | string | number; +}; + +/** + * This is a model with nested 'any of' property with a type null + */ +export type CompositionWithNestedAnyAndTypeNull = { + propA?: Array | Array; +}; + +export type _3eNum1Период = 'Bird' | 'Dog'; + +export type ConstValue = 'ConstValue'; + +/** + * This is a model with one property with a 'any of' relationship where the options are not $ref + */ +export type CompositionWithNestedAnyOfAndNull = { + /** + * Scopes + */ + propA?: Array<_3eNum1Период | ConstValue> | null; +}; + +/** + * This is a model with one property with a 'one of' relationship + */ +export type CompositionWithOneOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a model that contains a simple dictionary within composition + */ +export type CompositionWithOneOfAndSimpleDictionary = { + propA?: boolean | { + [key: string]: number; + }; +}; + +/** + * This is a model that contains a dictionary of simple arrays within composition + */ +export type CompositionWithOneOfAndSimpleArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model that contains a dictionary of complex arrays (composited) within composition + */ +export type CompositionWithOneOfAndComplexArrayDictionary = { + propA?: boolean | { + [key: string]: Array; + }; +}; + +/** + * This is a model with one property with a 'all of' relationship + */ +export type CompositionWithAllOfAndNullable = { + propA?: ({ + boolean?: boolean; + } & ModelWithEnum & ModelWithArray & ModelWithDictionary) | null; +}; + +/** + * This is a model with one property with a 'any of' relationship + */ +export type CompositionWithAnyOfAndNullable = { + propA?: { + boolean?: boolean; + } | ModelWithEnum | ModelWithArray | ModelWithDictionary | null; +}; + +/** + * This is a base model with two simple optional properties + */ +export type CompositionBaseModel = { + firstName?: string; + lastname?: string; +}; + +/** + * This is a model that extends the base model + */ +export type CompositionExtendedModel = CompositionBaseModel & { + age: number; + firstName: string; + lastname: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithProperties = { + required: string; + readonly requiredAndReadOnly: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithNestedProperties = { + readonly first: { + readonly second: { + readonly third: string | null; + } | null; + } | null; +}; + +/** + * This is a model with duplicated properties + */ +export type ModelWithDuplicateProperties = { + prop?: ModelWithString; +}; + +/** + * This is a model with ordered properties + */ +export type ModelWithOrderedProperties = { + zebra?: string; + apple?: string; + hawaii?: string; +}; + +/** + * This is a model with duplicated imports + */ +export type ModelWithDuplicateImports = { + propA?: ModelWithString; + propB?: ModelWithString; + propC?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtends = ModelWithString & { + propExtendsA?: string; + propExtendsB?: ModelWithString; +}; + +/** + * This is a model that extends another model + */ +export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { + propExtendsC?: string; + propExtendsD?: ModelWithString; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPattern = { + key: string; + name: string; + readonly enabled?: boolean; + readonly modified?: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type File = { + /** + * Id + */ + readonly id?: string; + /** + * Updated at + */ + readonly updated_at?: string; + /** + * Created at + */ + readonly created_at?: string; + /** + * Mime + */ + mime: string; + /** + * File + */ + readonly file?: string; +}; + +export type Default = { + name?: string; +}; + +export type Pageable = { + page?: number; + size?: number; + sort?: Array; +}; + +/** + * This is a free-form object without additionalProperties. + */ +export type FreeFormObjectWithoutAdditionalProperties = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: true. + */ +export type FreeFormObjectWithAdditionalPropertiesEqTrue = { + [key: string]: unknown; +}; + +/** + * This is a free-form object with additionalProperties: {}. + */ +export type FreeFormObjectWithAdditionalPropertiesEqEmptyObject = { + [key: string]: unknown; +}; + +export type ModelWithConst = { + String?: 'String'; + number?: 0; + null?: null; + withType?: 'Some string'; +}; + +/** + * This is a model with one property and additionalProperties: true + */ +export type ModelWithAdditionalPropertiesEqTrue = { + /** + * This is a simple string property + */ + prop?: string; + [key: string]: unknown | string | undefined; +}; + +export type NestedAnyOfArraysNullable = { + nullableArray?: Array | null; +}; + +export type CompositionWithOneOfAndProperties = ({ + foo: SimpleParameter; +} | { + bar: NonAsciiStringæøåÆøÅöôêÊ字符串; +}) & { + baz: number | null; + qux: number; +}; + +/** + * An object that can be null + */ +export type NullableObject = { + foo?: string; +} | null; + +/** + * Some % character + */ +export type CharactersInDescription = string; + +export type ModelWithNullableObject = { + data?: NullableObject; +}; + +export type ModelWithOneOfEnum = { + foo: 'Bar'; +} | { + foo: 'Baz'; +} | { + foo: 'Qux'; +} | { + content: string; + foo: 'Quux'; +} | { + content: [ + string, + string + ]; + foo: 'Corge'; +}; + +export type ModelWithNestedArrayEnumsDataFoo = 'foo' | 'bar'; + +export type ModelWithNestedArrayEnumsDataBar = 'baz' | 'qux'; + +export type ModelWithNestedArrayEnumsData = { + foo?: Array; + bar?: Array; +}; + +export type ModelWithNestedArrayEnums = { + array_strings?: Array; + data?: ModelWithNestedArrayEnumsData; +}; + +export type ModelWithNestedCompositionEnums = { + foo?: ModelWithNestedArrayEnumsDataFoo; +}; + +export type ModelWithReadOnlyAndWriteOnly = { + foo: string; + readonly bar: string; +}; + +export type ModelWithConstantSizeArray = [ + number, + number +]; + +export type ModelWithAnyOfConstantSizeArray = [ + number | string, + number | string, + number | string +]; + +export type ModelWithPrefixItemsConstantSizeArray = [ + ModelWithInteger, + number | string, + string +]; + +export type ModelWithAnyOfConstantSizeArrayNullable = [ + number | null | string, + number | null | string, + number | null | string +]; + +export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ + number | Import, + number | Import +]; + +export type ModelWithAnyOfConstantSizeArrayAndIntersect = [ + number & string, + number & string +]; + +export type ModelWithNumericEnumUnion = { + /** + * Период + */ + value?: -10 | -1 | 0 | 1 | 3 | 6 | 12; +}; + +/** + * Some description with `back ticks` + */ +export type ModelWithBackticksInDescription = { + /** + * The template `that` should be used for parsing and importing the contents of the CSV file. + * + *

There is one placeholder currently supported:

  • ${x} - refers to the n-th column in the CSV file, e.g. ${1}, ${2}, ...)

Example of a correct JSON template:

+ *
+     * [
+     * {
+     * "resourceType": "Asset",
+     * "identifier": {
+     * "name": "${1}",
+     * "domain": {
+     * "name": "${2}",
+     * "community": {
+     * "name": "Some Community"
+     * }
+     * }
+     * },
+     * "attributes" : {
+     * "00000000-0000-0000-0000-000000003115" : [ {
+     * "value" : "${3}"
+     * } ],
+     * "00000000-0000-0000-0000-000000000222" : [ {
+     * "value" : "${4}"
+     * } ]
+     * }
+     * }
+     * ]
+     * 
+ */ + template?: string; +}; + +export type ModelWithOneOfAndProperties = (SimpleParameter | NonAsciiStringæøåÆøÅöôêÊ字符串) & { + baz: number | null; + qux: number; +}; + +/** + * Model used to test deduplication strategy (unused) + */ +export type ParameterSimpleParameterUnused = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse = string; + +/** + * Model used to test deduplication strategy + */ +export type PostServiceWithEmptyTagResponse2 = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData = string; + +/** + * Model used to test deduplication strategy + */ +export type DeleteFooData2 = string; + +/** + * Model with restricted keyword name + */ +export type Import = string; + +export type SchemaWithFormRestrictedKeys = { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + object?: { + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }; + array?: Array<{ + description?: string; + 'x-enum-descriptions'?: string; + 'x-enum-varnames'?: string; + 'x-enumNames'?: string; + title?: string; + }>; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1DeleteOptions = { + /** + * Must be fulfilled before a deletion is carried out. If not possible, a 409 Conflict status will be returned. + */ + preconditions?: IoK8sApimachineryPkgApisMetaV1Preconditions; +}; + +/** + * This schema was giving PascalCase transformations a hard time + */ +export type IoK8sApimachineryPkgApisMetaV1Preconditions = { + /** + * Specifies the target ResourceVersion + */ + resourceVersion?: string; + /** + * Specifies the target UID. + */ + uid?: string; +}; + +export type AdditionalPropertiesUnknownIssue = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue2 = { + [key: string]: string | number; +}; + +export type AdditionalPropertiesUnknownIssue3 = string & { + entries: { + [key: string]: AdditionalPropertiesUnknownIssue; + }; +}; + +export type AdditionalPropertiesIntegerIssue = { + value: number; + [key: string]: number; +}; + +export type OneOfAllOfIssue = ((ConstValue | GenericSchemaDuplicateIssue1SystemBoolean) & _3eNum1Период) | GenericSchemaDuplicateIssue1SystemString; + +export type GenericSchemaDuplicateIssue1SystemBoolean = { + item?: boolean; + error?: string | null; + readonly hasError?: boolean; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemString = { + item?: string | null; + error?: string | null; + readonly hasError?: boolean; +}; + +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + +/** + * This is a model with one nested property + */ +export type ModelWithPropertiesWritable = { + required: string; + requiredAndNullable: string | null; + string?: string; + number?: number; + boolean?: boolean; + reference?: ModelWithString; + 'property with space'?: string; + default?: string; + try?: string; +}; + +/** + * This is a model that contains a some patterns + */ +export type ModelWithPatternWritable = { + key: string; + name: string; + id?: string; + text?: string; + patternWithSingleQuotes?: string; + patternWithNewline?: string; + patternWithBacktick?: string; +}; + +export type FileWritable = { + /** + * Mime + */ + mime: string; +}; + +export type ModelWithReadOnlyAndWriteOnlyWritable = { + foo: string; + baz: string; +}; + +export type AdditionalPropertiesUnknownIssueWritable = { + [key: string]: string | number; +}; + +export type GenericSchemaDuplicateIssue1SystemBooleanWritable = { + item?: boolean; + error?: string | null; + data?: { + [key: string]: never; + }; +}; + +export type GenericSchemaDuplicateIssue1SystemStringWritable = { + item?: string | null; + error?: string | null; +}; + +/** + * This is a reusable parameter + */ +export type SimpleParameter = string; + +/** + * Parameter with illegal characters + */ +export type XFooBar = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleRequestBody = ModelWithString; + +/** + * A reusable request body + */ +export type SimpleFormData = ModelWithString; + +export type ExportData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type PatchApiVbyApiVersionNoTagResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ImportData = { + body: ModelWithReadOnlyAndWriteOnlyWritable | ModelWithArrayReadOnlyAndWriteOnly; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type ImportResponses = { + /** + * Success + */ + 200: ModelFromZendesk; + /** + * Default success response + */ + default: ModelWithReadOnlyAndWriteOnly; +}; + +export type ImportResponse = ImportResponses[keyof ImportResponses]; + +export type FooWowData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no+tag'; +}; + +export type FooWowResponses = { + /** + * OK + */ + default: unknown; +}; + +export type ApiVVersionODataControllerCountData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple/$count'; +}; + +export type ApiVVersionODataControllerCountResponses = { + /** + * Success + */ + 200: ModelFromZendesk; +}; + +export type ApiVVersionODataControllerCountResponse = ApiVVersionODataControllerCountResponses[keyof ApiVVersionODataControllerCountResponses]; + +export type GetApiVbyApiVersionSimpleOperationData = { + body?: never; + path: { + /** + * foo in method + */ + foo_param: string; + }; + query?: never; + url: '/api/v{api-version}/simple:operation'; +}; + +export type GetApiVbyApiVersionSimpleOperationErrors = { + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type GetApiVbyApiVersionSimpleOperationError = GetApiVbyApiVersionSimpleOperationErrors[keyof GetApiVbyApiVersionSimpleOperationErrors]; + +export type GetApiVbyApiVersionSimpleOperationResponses = { + /** + * Response is a simple number + */ + 200: number; +}; + +export type GetApiVbyApiVersionSimpleOperationResponse = GetApiVbyApiVersionSimpleOperationResponses[keyof GetApiVbyApiVersionSimpleOperationResponses]; + +export type DeleteCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type GetCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type HeadCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type OptionsCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PatchCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PostCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type PutCallWithoutParametersAndResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/simple'; +}; + +export type DeleteFooData3 = { + body?: never; + headers: { + /** + * Parameter with illegal characters + */ + 'x-Foo-Bar': ModelWithString; + }; + path: { + /** + * foo in method + */ + foo_param: string; + /** + * bar in method + */ + BarParam: string; + }; + query?: never; + url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}'; +}; + +export type CallWithDescriptionsData = { + body?: never; + path?: never; + query?: { + /** + * Testing multiline comments in string: First line + * Second line + * + * Fourth line + */ + parameterWithBreaks?: string; + /** + * Testing backticks in string: `backticks` and ```multiple backticks``` should work + */ + parameterWithBackticks?: string; + /** + * Testing slashes in string: \backwards\\\ and /forwards/// should work + */ + parameterWithSlashes?: string; + /** + * Testing expression placeholders in string: ${expression} should work + */ + parameterWithExpressionPlaceholders?: string; + /** + * Testing quotes in string: 'single quote''' and "double quotes""" should work + */ + parameterWithQuotes?: string; + /** + * Testing reserved characters in string: * inline * and ** inline ** should work + */ + parameterWithReservedCharacters?: string; + }; + url: '/api/v{api-version}/descriptions'; +}; + +export type DeprecatedCallData = { + body?: never; + headers: { + /** + * This parameter is deprecated + * @deprecated + */ + parameter: DeprecatedModel | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/parameters/deprecated'; +}; + +export type CallWithParametersData = { + /** + * This is the parameter that goes into the body + */ + body: { + [key: string]: unknown; + } | null; + headers: { + /** + * This is the parameter that goes into the header + */ + parameterHeader: string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + parameterPath: string | null; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + foo_ref_enum?: ModelWithNestedArrayEnumsDataFoo; + foo_all_of_enum: ModelWithNestedArrayEnumsDataFoo; + /** + * This is the parameter that goes into the query params + */ + cursor: string | null; + }; + url: '/api/v{api-version}/parameters/{parameterPath}'; +}; + +export type CallWithWeirdParameterNamesData = { + /** + * This is the parameter that goes into the body + */ + body: ModelWithString | null; + headers: { + /** + * This is the parameter that goes into the request header + */ + 'parameter.header': string | null; + }; + path: { + /** + * This is the parameter that goes into the path + */ + 'parameter.path.1'?: string; + /** + * This is the parameter that goes into the path + */ + 'parameter-path-2'?: string; + /** + * This is the parameter that goes into the path + */ + 'PARAMETER-PATH-3'?: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query: { + /** + * This is the parameter with a reserved keyword + */ + default?: string; + /** + * This is the parameter that goes into the request query params + */ + 'parameter-query': string | null; + }; + url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}'; +}; + +export type GetCallWithOptionalParamData = { + /** + * This is a required parameter + */ + body: ModelWithOneOfEnum; + path?: never; + query?: { + /** + * This is an optional parameter + */ + page?: number; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamData = { + /** + * This is an optional parameter + */ + body?: { + offset?: number | null; + }; + path?: never; + query: { + /** + * This is a required parameter + */ + parameter: Pageable; + }; + url: '/api/v{api-version}/parameters'; +}; + +export type PostCallWithOptionalParamResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type PostCallWithOptionalParamResponse = PostCallWithOptionalParamResponses[keyof PostCallWithOptionalParamResponses]; + +export type PostApiVbyApiVersionRequestBodyData = { + /** + * A reusable request body + */ + body?: SimpleRequestBody; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/requestBody'; +}; + +export type PostApiVbyApiVersionFormDataData = { + /** + * A reusable request body + */ + body?: SimpleFormData; + path?: never; + query?: { + /** + * This is a reusable parameter + */ + parameter?: string; + }; + url: '/api/v{api-version}/formData'; +}; + +export type CallWithDefaultParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string with default value + */ + parameterString?: string | null; + /** + * This is a simple number with default value + */ + parameterNumber?: number | null; + /** + * This is a simple boolean with default value + */ + parameterBoolean?: boolean | null; + /** + * This is a simple enum with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model with default value + */ + parameterModel?: ModelWithString | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallWithDefaultOptionalParametersData = { + body?: never; + path?: never; + query?: { + /** + * This is a simple string that is optional with default value + */ + parameterString?: string; + /** + * This is a simple number that is optional with default value + */ + parameterNumber?: number; + /** + * This is a simple boolean that is optional with default value + */ + parameterBoolean?: boolean; + /** + * This is a simple enum that is optional with default value + */ + parameterEnum?: 'Success' | 'Warning' | 'Error'; + /** + * This is a simple model that is optional with default value + */ + parameterModel?: ModelWithString; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type CallToTestOrderOfParamsData = { + body?: never; + path?: never; + query: { + /** + * This is a optional string with default + */ + parameterOptionalStringWithDefault?: string; + /** + * This is a optional string with empty default + */ + parameterOptionalStringWithEmptyDefault?: string; + /** + * This is a optional string with no default + */ + parameterOptionalStringWithNoDefault?: string; + /** + * This is a string with default + */ + parameterStringWithDefault: string; + /** + * This is a string with empty default + */ + parameterStringWithEmptyDefault: string; + /** + * This is a string with no default + */ + parameterStringWithNoDefault: string; + /** + * This is a string that can be null with no default + */ + parameterStringNullableWithNoDefault?: string | null; + /** + * This is a string that can be null with default + */ + parameterStringNullableWithDefault?: string | null; + }; + url: '/api/v{api-version}/defaults'; +}; + +export type DuplicateNameData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName2Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName3Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type DuplicateName4Data = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/duplicate'; +}; + +export type CallWithNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/no-content'; +}; + +export type CallWithNoContentResponseResponses = { + /** + * Success + */ + 204: void; +}; + +export type CallWithNoContentResponseResponse = CallWithNoContentResponseResponses[keyof CallWithNoContentResponseResponses]; + +export type CallWithResponseAndNoContentResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/response-and-no-content'; +}; + +export type CallWithResponseAndNoContentResponseResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Success + */ + 204: void; +}; + +export type CallWithResponseAndNoContentResponseResponse = CallWithResponseAndNoContentResponseResponses[keyof CallWithResponseAndNoContentResponseResponses]; + +export type DummyAData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/a'; +}; + +export type DummyAResponses = { + 200: _400; +}; + +export type DummyAResponse = DummyAResponses[keyof DummyAResponses]; + +export type DummyBData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multiple-tags/b'; +}; + +export type DummyBResponses = { + /** + * Success + */ + 204: void; +}; + +export type DummyBResponse = DummyBResponses[keyof DummyBResponses]; + +export type CallWithResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponseResponses = { + default: Import; +}; + +export type CallWithResponseResponse = CallWithResponseResponses[keyof CallWithResponseResponses]; + +export type CallWithDuplicateResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithDuplicateResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for 4XX errors + */ + '4XX': DictionaryWithArray; + /** + * Default error response + */ + default: ModelWithBoolean; +}; + +export type CallWithDuplicateResponsesError = CallWithDuplicateResponsesErrors[keyof CallWithDuplicateResponsesErrors]; + +export type CallWithDuplicateResponsesResponses = { + /** + * Message for 200 response + */ + 200: ModelWithBoolean & ModelWithInteger; + /** + * Message for 201 response + */ + 201: ModelWithString; + /** + * Message for 202 response + */ + 202: ModelWithString; +}; + +export type CallWithDuplicateResponsesResponse = CallWithDuplicateResponsesResponses[keyof CallWithDuplicateResponsesResponses]; + +export type CallWithResponsesData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/response'; +}; + +export type CallWithResponsesErrors = { + /** + * Message for 500 error + */ + 500: ModelWithStringError; + /** + * Message for 501 error + */ + 501: ModelWithStringError; + /** + * Message for 502 error + */ + 502: ModelWithStringError; + /** + * Message for default response + */ + default: ModelWithStringError; +}; + +export type CallWithResponsesError = CallWithResponsesErrors[keyof CallWithResponsesErrors]; + +export type CallWithResponsesResponses = { + /** + * Message for 200 response + */ + 200: { + readonly '@namespace.string'?: string; + readonly '@namespace.integer'?: number; + readonly value?: Array; + }; + /** + * Message for 201 response + */ + 201: ModelThatExtends; + /** + * Message for 202 response + */ + 202: ModelThatExtendsExtends; +}; + +export type CallWithResponsesResponse = CallWithResponsesResponses[keyof CallWithResponsesResponses]; + +export type CollectionFormatData = { + body?: never; + path?: never; + query: { + /** + * This is an array parameter that is sent as csv format (comma-separated values) + */ + parameterArrayCSV: Array | null; + /** + * This is an array parameter that is sent as ssv format (space-separated values) + */ + parameterArraySSV: Array | null; + /** + * This is an array parameter that is sent as tsv format (tab-separated values) + */ + parameterArrayTSV: Array | null; + /** + * This is an array parameter that is sent as pipes format (pipe-separated values) + */ + parameterArrayPipes: Array | null; + /** + * This is an array parameter that is sent as multi format (multiple parameter instances) + */ + parameterArrayMulti: Array | null; + }; + url: '/api/v{api-version}/collectionFormat'; +}; + +export type TypesData = { + body?: never; + path?: { + /** + * This is a number parameter + */ + id?: number; + }; + query: { + /** + * This is a number parameter + */ + parameterNumber: number; + /** + * This is a string parameter + */ + parameterString: string | null; + /** + * This is a boolean parameter + */ + parameterBoolean: boolean | null; + /** + * This is an object parameter + */ + parameterObject: { + [key: string]: unknown; + } | null; + /** + * This is an array parameter + */ + parameterArray: Array | null; + /** + * This is a dictionary parameter + */ + parameterDictionary: { + [key: string]: unknown; + } | null; + /** + * This is an enum parameter + */ + parameterEnum: 'Success' | 'Warning' | 'Error' | null; + }; + url: '/api/v{api-version}/types'; +}; + +export type TypesResponses = { + /** + * Response is a simple number + */ + 200: number; + /** + * Response is a simple string + */ + 201: string; + /** + * Response is a simple boolean + */ + 202: boolean; + /** + * Response is a simple object + */ + 203: { + [key: string]: unknown; + }; +}; + +export type TypesResponse = TypesResponses[keyof TypesResponses]; + +export type UploadFileData = { + body: Blob | File; + path: { + /** + * api-version should be required in standalone clients + */ + 'api-version': string | null; + }; + query?: never; + url: '/api/v{api-version}/upload'; +}; + +export type UploadFileResponses = { + 200: boolean; +}; + +export type UploadFileResponse = UploadFileResponses[keyof UploadFileResponses]; + +export type FileResponseData = { + body?: never; + path: { + id: string; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/file/{id}'; +}; + +export type FileResponseResponses = { + /** + * Success + */ + 200: Blob | File; +}; + +export type FileResponseResponse = FileResponseResponses[keyof FileResponseResponses]; + +export type ComplexTypesData = { + body?: never; + path?: never; + query: { + /** + * Parameter containing object + */ + parameterObject: { + first?: { + second?: { + third?: string; + }; + }; + }; + /** + * Parameter containing reference + */ + parameterReference: ModelWithString; + }; + url: '/api/v{api-version}/complex'; +}; + +export type ComplexTypesErrors = { + /** + * 400 `server` error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type ComplexTypesResponses = { + /** + * Successful response + */ + 200: Array; +}; + +export type ComplexTypesResponse = ComplexTypesResponses[keyof ComplexTypesResponses]; + +export type MultipartResponseData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type MultipartResponseResponses = { + /** + * OK + */ + 200: { + file?: Blob | File; + metadata?: { + foo?: string; + bar?: string; + }; + }; +}; + +export type MultipartResponseResponse = MultipartResponseResponses[keyof MultipartResponseResponses]; + +export type MultipartRequestData = { + body?: { + content?: Blob | File; + data?: ModelWithString | null; + }; + path?: never; + query?: never; + url: '/api/v{api-version}/multipart'; +}; + +export type ComplexParamsData = { + body?: { + readonly key: string | null; + name: string | null; + enabled?: boolean; + type: 'Monkey' | 'Horse' | 'Bird'; + listOfModels?: Array | null; + listOfStrings?: Array | null; + parameters: ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary; + readonly user?: { + readonly id?: number; + readonly name?: string | null; + }; + }; + path: { + id: number; + /** + * api-version should be required in standalone clients + */ + 'api-version': string; + }; + query?: never; + url: '/api/v{api-version}/complex/{id}'; +}; + +export type ComplexParamsResponses = { + /** + * Success + */ + 200: ModelWithString; +}; + +export type ComplexParamsResponse = ComplexParamsResponses[keyof ComplexParamsResponses]; + +export type CallWithResultFromHeaderData = { + body?: never; + path?: never; + query?: never; + url: '/api/v{api-version}/header'; +}; + +export type CallWithResultFromHeaderErrors = { + /** + * 400 server error + */ + 400: unknown; + /** + * 500 server error + */ + 500: unknown; +}; + +export type CallWithResultFromHeaderResponses = { + /** + * Successful response + */ + 200: unknown; +}; + +export type TestErrorCodeData = { + body?: never; + path?: never; + query: { + /** + * Status code to return + */ + status: number; + }; + url: '/api/v{api-version}/error'; +}; + +export type TestErrorCodeErrors = { + /** + * Custom message: Internal Server Error + */ + 500: unknown; + /** + * Custom message: Not Implemented + */ + 501: unknown; + /** + * Custom message: Bad Gateway + */ + 502: unknown; + /** + * Custom message: Service Unavailable + */ + 503: unknown; +}; + +export type TestErrorCodeResponses = { + /** + * Custom message: Successful response + */ + 200: unknown; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Data = { + body?: never; + path?: never; + query: { + /** + * Dummy input param + */ + nonAsciiParamæøåÆØÅöôêÊ: number; + }; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Responses = { + /** + * Successful response + */ + 200: Array; +}; + +export type NonAsciiæøåÆøÅöôêÊ字符串Response = NonAsciiæøåÆøÅöôêÊ字符串Responses[keyof NonAsciiæøåÆøÅöôêÊ字符串Responses]; + +export type PutWithFormUrlEncodedData = { + body: ArrayWithStrings; + path?: never; + query?: never; + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; +}; + +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts index 55e9ad934..ab470cc11 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/schemas/default/schemas.gen.ts @@ -7,21 +7,12 @@ export const _400Schema = { export const ExternalRefASchema = { description: 'External ref to shared model (A)', - type: 'object', - properties: { - id: { - type: 'string' - }, - name: { - type: 'string' - } - }, - required: ['id'] + '$ref': '#/components/schemas/external-shared_ExternalSharedModel' } as const; export const ExternalRefBSchema = { description: 'External ref to shared model (B)', - '$ref': '#/components/schemas/ExternalRefA' + '$ref': '#/components/schemas/external-shared_ExternalSharedModel' } as const; export const camelCaseCommentWithBreaksSchema = { @@ -1993,6 +1984,19 @@ export const Generic_Schema_Duplicate_Issue_1_System_String_Schema = { additionalProperties: false } as const; +export const external_shared_ExternalSharedModelSchema = { + type: 'object', + properties: { + id: { + type: 'string' + }, + name: { + type: 'string' + } + }, + required: ['id'] +} as const; + export const ModelWithPropertiesWritableSchema = { description: 'This is a model with one nested property', type: 'object', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts index eac22bf7c..83b5f6181 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts index 8bfc7d0f5..4c755476d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/types.gen.ts @@ -8,15 +8,12 @@ export type _400 = string; /** * External ref to shared model (A) */ -export type ExternalRefA = { - id: string; - name?: string; -}; +export type ExternalRefA = ExternalSharedExternalSharedModel; /** * External ref to shared model (B) */ -export type ExternalRefB = ExternalRefA; +export type ExternalRefB = ExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line @@ -974,6 +971,11 @@ export type GenericSchemaDuplicateIssue1SystemString = { readonly hasError?: boolean; }; +export type ExternalSharedExternalSharedModel = { + id: string; + name?: string; +}; + /** * This is a model with one nested property */ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts index f59a1aa5d..973798655 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts @@ -7,18 +7,20 @@ import * as v from 'valibot'; */ export const v400 = v.string(); -/** - * External ref to shared model (A) - */ -export const vExternalRefA = v.object({ +export const vExternalSharedExternalSharedModel = v.object({ id: v.string(), name: v.optional(v.string()) }); +/** + * External ref to shared model (A) + */ +export const vExternalRefA = vExternalSharedExternalSharedModel; + /** * External ref to shared model (B) */ -export const vExternalRefB = vExternalRefA; +export const vExternalRefB = vExternalSharedExternalSharedModel; /** * Testing multiline comments in string: First line diff --git a/packages/openapi-ts-tests/main/test/plugins.test.ts b/packages/openapi-ts-tests/main/test/plugins.test.ts index 4d5e9e832..f2c84dcd1 100644 --- a/packages/openapi-ts-tests/main/test/plugins.test.ts +++ b/packages/openapi-ts-tests/main/test/plugins.test.ts @@ -519,6 +519,30 @@ for (const version of versions) { }), description: 'generate Fetch API client with Pinia Colada plugin', }, + { + config: createConfig({ + output: 'default', + plugins: ['@angular/common'], + }), + description: 'generate Angular requests and resources', + }, + { + config: createConfig({ + output: 'default-class', + plugins: [ + { + httpRequests: { + asClass: true, + }, + httpResources: { + asClass: true, + }, + name: '@angular/common', + }, + ], + }), + description: 'generate Angular requests and resources (class)', + }, ]; it.each(scenarios)('$description', async ({ config }) => { diff --git a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts index 30bc7baad..ca4b4b14d 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts @@ -428,7 +428,7 @@ const generateAngularRequestFunction = ({ export const createHttpRequests: AngularCommonPlugin['Handler'] = ({ plugin, }) => { - plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { + const f = plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { extension: '.ts', path: '{{path}}.gen', renderer: new TypeScriptRenderer(), @@ -439,4 +439,9 @@ export const createHttpRequests: AngularCommonPlugin['Handler'] = ({ } else { generateAngularFunctionRequests({ plugin }); } + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; diff --git a/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts b/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts index 2213bca28..1712a8fa8 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts @@ -512,7 +512,7 @@ const generateAngularResourceFunction = ({ export const createHttpResources: AngularCommonPlugin['Handler'] = ({ plugin, }) => { - plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { + const f = plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { extension: '.ts', path: '{{path}}.gen', renderer: new TypeScriptRenderer(), @@ -523,4 +523,9 @@ export const createHttpResources: AngularCommonPlugin['Handler'] = ({ } else { generateAngularFunctionServices({ plugin }); } + + if (plugin.config.exportFromIndex && f.hasContent()) { + const index = plugin.gen.ensureFile('index'); + index.addExport({ from: f, namespaceImport: true }); + } }; From 10aea8910771ff72ef9b08d4eacdd6b028833c4c Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 02:19:21 +0800 Subject: [PATCH 3/5] docs: add changelog --- .changeset/brown-paws-design.md | 5 +++++ .changeset/cuddly-bears-deny.md | 5 +++++ .changeset/thirty-shoes-end.md | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 .changeset/brown-paws-design.md create mode 100644 .changeset/cuddly-bears-deny.md create mode 100644 .changeset/thirty-shoes-end.md diff --git a/.changeset/brown-paws-design.md b/.changeset/brown-paws-design.md new file mode 100644 index 000000000..a3a5f9f0e --- /dev/null +++ b/.changeset/brown-paws-design.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': minor +--- + +feat: add symbol api diff --git a/.changeset/cuddly-bears-deny.md b/.changeset/cuddly-bears-deny.md new file mode 100644 index 000000000..3082d56aa --- /dev/null +++ b/.changeset/cuddly-bears-deny.md @@ -0,0 +1,5 @@ +--- +'@hey-api/codegen-core': minor +--- + +feat: expand symbol api diff --git a/.changeset/thirty-shoes-end.md b/.changeset/thirty-shoes-end.md new file mode 100644 index 000000000..8acacc334 --- /dev/null +++ b/.changeset/thirty-shoes-end.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': minor +--- + +feat(pinia-colada): remove groupByTag option From 1cc2f0dad4bb46a63e27b81941a57d54e92d0fb1 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 02:23:41 +0800 Subject: [PATCH 4/5] chore: fix lint errors --- packages/codegen-core/src/__tests__/file.ts | 3 + .../src/__tests__/project.test.ts | 10 ++ .../src/__tests__/renderer.test.ts | 9 +- .../@angular/common/http/requests.gen.ts | 34 ++-- .../@angular/common/http/resources.gen.ts | 112 ++++++------ .../common/default-class/client.gen.ts | 18 +- .../@angular/common/default/client.gen.ts | 18 +- .../angular-query-experimental.gen.ts | 2 +- .../asClass/@tanstack/react-query.gen.ts | 2 +- .../asClass/@tanstack/solid-query.gen.ts | 2 +- .../asClass/@tanstack/svelte-query.gen.ts | 2 +- .../asClass/@tanstack/vue-query.gen.ts | 2 +- .../@angular/common/http/requests.gen.ts | 58 +++---- .../@angular/common/http/resources.gen.ts | 164 +++++++++--------- .../common/default-class/client.gen.ts | 18 +- .../@angular/common/default/client.gen.ts | 18 +- .../angular-query-experimental.gen.ts | 2 +- .../asClass/@tanstack/react-query.gen.ts | 2 +- .../asClass/@tanstack/solid-query.gen.ts | 2 +- .../asClass/@tanstack/svelte-query.gen.ts | 2 +- .../asClass/@tanstack/vue-query.gen.ts | 2 +- .../@angular/common/http/requests.gen.ts | 58 +++---- .../@angular/common/http/resources.gen.ts | 164 +++++++++--------- .../common/default-class/client.gen.ts | 18 +- .../@angular/common/default/client.gen.ts | 18 +- .../angular-query-experimental.gen.ts | 2 +- .../asClass/@tanstack/react-query.gen.ts | 2 +- .../asClass/@tanstack/solid-query.gen.ts | 2 +- .../asClass/@tanstack/svelte-query.gen.ts | 2 +- .../asClass/@tanstack/vue-query.gen.ts | 2 +- .../main/test/openapi-ts.config.ts | 9 +- .../main/test/plugins.test.ts | 20 ++- .../src/generate/__tests__/class.test.ts | 8 +- .../src/generate/__tests__/core.test.ts | 24 ++- .../generate/legacy/__tests__/index.test.ts | 8 +- .../generate/legacy/__tests__/output.test.ts | 8 +- .../common/parser/__tests__/type.test.ts | 2 +- .../v3/parser/__tests__/getModel.test.ts | 2 +- .../schemas/__tests__/schemas.test.ts | 16 +- .../@hey-api/sdk/__tests__/plugin.test.ts | 32 +++- .../typescript/__tests__/plugin.test.ts | 8 +- .../src/plugins/@pinia/colada/plugin.ts | 13 +- .../plugins/@tanstack/query-core/plugin.ts | 13 +- .../src/utils/__tests__/handlebars.test.ts | 16 +- .../src/utils/__tests__/parse.test.ts | 21 +++ 45 files changed, 507 insertions(+), 443 deletions(-) diff --git a/packages/codegen-core/src/__tests__/file.ts b/packages/codegen-core/src/__tests__/file.ts index 22240de86..911a24457 100644 --- a/packages/codegen-core/src/__tests__/file.ts +++ b/packages/codegen-core/src/__tests__/file.ts @@ -1,5 +1,8 @@ /* @ts-nocheck */ +type _heyapi_5_ = string; +type _heyapi_4_ = () => _heyapi_5_; + /** * something about _heyapi_1_. Did you know that __heyapi_1__? */ diff --git a/packages/codegen-core/src/__tests__/project.test.ts b/packages/codegen-core/src/__tests__/project.test.ts index a8fc02f60..3d1e6d9e2 100644 --- a/packages/codegen-core/src/__tests__/project.test.ts +++ b/packages/codegen-core/src/__tests__/project.test.ts @@ -1,6 +1,7 @@ import { beforeEach, describe, expect, it } from 'vitest'; import { CodegenFile } from '../files/file'; +import type { ICodegenFile } from '../files/types'; import type { ICodegenMeta } from '../meta/types'; import { CodegenProject } from '../project/project'; import type { ICodegenRenderer } from '../renderers/types'; @@ -101,6 +102,15 @@ describe('CodegenProject', () => { renderSymbols(file: CodegenFile, _meta?: ICodegenMeta): string { return `content ${file.path}`; } + // eslint-disable-next-line @typescript-eslint/no-unused-vars + replacerFn(_args: { + file: ICodegenFile; + headless?: boolean; + scope?: 'file' | 'project'; + symbolId: number; + }): string | undefined { + return undefined; + } } const renderer = new Renderer(); const meta = { foo: 42 }; diff --git a/packages/codegen-core/src/__tests__/renderer.test.ts b/packages/codegen-core/src/__tests__/renderer.test.ts index df7b12226..efaf438a6 100644 --- a/packages/codegen-core/src/__tests__/renderer.test.ts +++ b/packages/codegen-core/src/__tests__/renderer.test.ts @@ -15,20 +15,23 @@ describe('replaceWrappedIds', () => { 1: 'Foo', 12: 'baz', 2: 'bar', - 4: '() => string', - 5: 'string', + 4: 'Bar', + 5: 'Foo', }; const replaced = replaceWrappedIds(source, (id) => substitutions[id]); expect(replaced).toEqual(`/* @ts-nocheck */ +type Foo = string; +type Bar = () => Foo; + /** * something about Foo. Did you know that _Foo_? */ export class Foo { // Foo is great! - bar(baz: ReturnType<() => string>): string { + bar(baz: ReturnType): Foo { return baz; } } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts index 9a948d5c3..1f9271d48 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts @@ -9,7 +9,7 @@ import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class DefaultRequests { +export class DefaultServiceRequests { public serviceWithEmptyTag(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -54,7 +54,7 @@ export class DefaultRequests { @Injectable({ providedIn: 'root' }) -export class SimpleRequests { +export class SimpleServiceRequests { public deleteCallWithoutParametersAndResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -122,7 +122,7 @@ export class SimpleRequests { @Injectable({ providedIn: 'root' }) -export class DescriptionsRequests { +export class DescriptionsServiceRequests { public callWithDescriptions(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -136,7 +136,7 @@ export class DescriptionsRequests { @Injectable({ providedIn: 'root' }) -export class ParametersRequests { +export class ParametersServiceRequests { public callWithParameters(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -159,7 +159,7 @@ export class ParametersRequests { @Injectable({ providedIn: 'root' }) -export class DefaultsRequests { +export class DefaultsServiceRequests { public callWithDefaultParameters(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -191,7 +191,7 @@ export class DefaultsRequests { @Injectable({ providedIn: 'root' }) -export class DuplicateRequests { +export class DuplicateServiceRequests { public duplicateName(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -232,7 +232,7 @@ export class DuplicateRequests { @Injectable({ providedIn: 'root' }) -export class NoContentRequests { +export class NoContentServiceRequests { public callWithNoContentResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -255,7 +255,7 @@ export class NoContentRequests { @Injectable({ providedIn: 'root' }) -export class ResponseRequests { +export class ResponseServiceRequests { public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -296,7 +296,7 @@ export class ResponseRequests { @Injectable({ providedIn: 'root' }) -export class MultipleTags1Requests { +export class MultipleTags1ServiceRequests { public dummyA(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -319,7 +319,7 @@ export class MultipleTags1Requests { @Injectable({ providedIn: 'root' }) -export class MultipleTags2Requests { +export class MultipleTags2ServiceRequests { public dummyA(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -342,7 +342,7 @@ export class MultipleTags2Requests { @Injectable({ providedIn: 'root' }) -export class MultipleTags3Requests { +export class MultipleTags3ServiceRequests { public dummyB(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -356,7 +356,7 @@ export class MultipleTags3Requests { @Injectable({ providedIn: 'root' }) -export class CollectionFormatRequests { +export class CollectionFormatServiceRequests { public collectionFormat(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -370,7 +370,7 @@ export class CollectionFormatRequests { @Injectable({ providedIn: 'root' }) -export class TypesRequests { +export class TypesServiceRequests { public types(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -384,7 +384,7 @@ export class TypesRequests { @Injectable({ providedIn: 'root' }) -export class ComplexRequests { +export class ComplexServiceRequests { public complexTypes(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -398,7 +398,7 @@ export class ComplexRequests { @Injectable({ providedIn: 'root' }) -export class HeaderRequests { +export class HeaderServiceRequests { public callWithResultFromHeader(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -412,7 +412,7 @@ export class HeaderRequests { @Injectable({ providedIn: 'root' }) -export class ErrorRequests { +export class ErrorServiceRequests { public testErrorCode(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -426,7 +426,7 @@ export class ErrorRequests { @Injectable({ providedIn: 'root' }) -export class NonAsciiÆøåÆøÅöôêÊRequests { +export class NonAsciiÆøåÆøÅöôêÊServiceRequests { public nonAsciiæøåÆøÅöôêÊ字符串(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts index e5da517b1..53da1170d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts @@ -3,31 +3,31 @@ import type { Options } from '../../../sdk.gen'; import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyBData, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, ComplexTypesData, ComplexTypesResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse } from '../../../types.gen'; import { httpResource } from '@angular/common/http'; -import { DefaultRequests, SimpleRequests, DescriptionsRequests, ParametersRequests, DefaultsRequests, DuplicateRequests, NoContentRequests, ResponseRequests, MultipleTags1Requests, CollectionFormatRequests, TypesRequests, ComplexRequests, HeaderRequests, ErrorRequests, NonAsciiÆøåÆøÅöôêÊRequests } from './requests.gen'; +import { DefaultServiceRequests, SimpleServiceRequests, DescriptionsServiceRequests, ParametersServiceRequests, DefaultsServiceRequests, DuplicateServiceRequests, NoContentServiceRequests, ResponseServiceRequests, MultipleTags1ServiceRequests, CollectionFormatServiceRequests, TypesServiceRequests, ComplexServiceRequests, HeaderServiceRequests, ErrorServiceRequests, NonAsciiÆøåÆøÅöôêÊServiceRequests } from './requests.gen'; import { inject, Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class DefaultResources { +export class DefaultServiceResources { public serviceWithEmptyTag(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).serviceWithEmptyTag(opts) : undefined; + return opts ? inject(DefaultServiceRequests).serviceWithEmptyTag(opts) : undefined; }); } public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; }); } public fooWow(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).fooWow(opts) : undefined; + return opts ? inject(DefaultServiceRequests).fooWow(opts) : undefined; }); } @@ -38,7 +38,7 @@ export class DefaultResources { public postApiVbyApiVersionBody(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).postApiVbyApiVersionBody(opts) : undefined; + return opts ? inject(DefaultServiceRequests).postApiVbyApiVersionBody(opts) : undefined; }); } } @@ -46,53 +46,53 @@ export class DefaultResources { @Injectable({ providedIn: 'root' }) -export class SimpleResources { +export class SimpleServiceResources { public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; }); } public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).getCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; }); } public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).headCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; }); } public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; }); } public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; }); } public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).postCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; }); } public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).putCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; }); } } @@ -100,11 +100,11 @@ export class SimpleResources { @Injectable({ providedIn: 'root' }) -export class DescriptionsResources { +export class DescriptionsServiceResources { public callWithDescriptions(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DescriptionsRequests).callWithDescriptions(opts) : undefined; + return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; }); } } @@ -112,18 +112,18 @@ export class DescriptionsResources { @Injectable({ providedIn: 'root' }) -export class ParametersResources { +export class ParametersServiceResources { public callWithParameters(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).callWithParameters(opts) : undefined; + return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; }); } public callWithWeirdParameterNames(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).callWithWeirdParameterNames(opts) : undefined; + return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; }); } } @@ -131,25 +131,25 @@ export class ParametersResources { @Injectable({ providedIn: 'root' }) -export class DefaultsResources { +export class DefaultsServiceResources { public callWithDefaultParameters(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callWithDefaultParameters(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; }); } public callWithDefaultOptionalParameters(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callWithDefaultOptionalParameters(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; }); } public callToTestOrderOfParams(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callToTestOrderOfParams(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; }); } } @@ -157,32 +157,32 @@ export class DefaultsResources { @Injectable({ providedIn: 'root' }) -export class DuplicateResources { +export class DuplicateServiceResources { public duplicateName(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; }); } public duplicateName2(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName2(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; }); } public duplicateName3(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName3(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; }); } public duplicateName4(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName4(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; }); } } @@ -190,18 +190,18 @@ export class DuplicateResources { @Injectable({ providedIn: 'root' }) -export class NoContentResources { +export class NoContentServiceResources { public callWithNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NoContentRequests).callWithNoContentResponse(opts) : undefined; + return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; }); } public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; }); } } @@ -209,32 +209,32 @@ export class NoContentResources { @Injectable({ providedIn: 'root' }) -export class ResponseResources { +export class ResponseServiceResources { public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; }); } public callWithResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; }); } public callWithDuplicateResponses(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithDuplicateResponses(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; }); } public callWithResponses(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponses(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; }); } } @@ -242,18 +242,18 @@ export class ResponseResources { @Injectable({ providedIn: 'root' }) -export class MultipleTags1Resources { +export class MultipleTags1ServiceResources { public dummyA(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; }); } public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -261,18 +261,18 @@ export class MultipleTags1Resources { @Injectable({ providedIn: 'root' }) -export class MultipleTags2Resources { +export class MultipleTags2ServiceResources { public dummyA(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; }); } public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -280,11 +280,11 @@ export class MultipleTags2Resources { @Injectable({ providedIn: 'root' }) -export class MultipleTags3Resources { +export class MultipleTags3ServiceResources { public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -292,11 +292,11 @@ export class MultipleTags3Resources { @Injectable({ providedIn: 'root' }) -export class CollectionFormatResources { +export class CollectionFormatServiceResources { public collectionFormat(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(CollectionFormatRequests).collectionFormat(opts) : undefined; + return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; }); } } @@ -304,11 +304,11 @@ export class CollectionFormatResources { @Injectable({ providedIn: 'root' }) -export class TypesResources { +export class TypesServiceResources { public types(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(TypesRequests).types(opts) : undefined; + return opts ? inject(TypesServiceRequests).types(opts) : undefined; }); } } @@ -316,11 +316,11 @@ export class TypesResources { @Injectable({ providedIn: 'root' }) -export class ComplexResources { +export class ComplexServiceResources { public complexTypes(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ComplexRequests).complexTypes(opts) : undefined; + return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; }); } } @@ -328,11 +328,11 @@ export class ComplexResources { @Injectable({ providedIn: 'root' }) -export class HeaderResources { +export class HeaderServiceResources { public callWithResultFromHeader(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(HeaderRequests).callWithResultFromHeader(opts) : undefined; + return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; }); } } @@ -340,11 +340,11 @@ export class HeaderResources { @Injectable({ providedIn: 'root' }) -export class ErrorResources { +export class ErrorServiceResources { public testErrorCode(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ErrorRequests).testErrorCode(opts) : undefined; + return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; }); } } @@ -352,11 +352,11 @@ export class ErrorResources { @Injectable({ providedIn: 'root' }) -export class NonAsciiÆøåÆøÅöôêÊResources { +export class NonAsciiÆøåÆøÅöôêÊServiceResources { public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; }); } } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts index 2e5fe1c9b..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client.gen.ts @@ -11,22 +11,8 @@ import { type ClientOptions as DefaultClientOptions, type Config, createClient, * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ -export type CreateClientConfig = (override?: Config2) => Config2 & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient2(createConfig2({ - baseUrl: 'http://localhost:3000/base' -})); - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig2 = (override?: Config) => Config & T>; - -export const client2 = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' })); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts index 2e5fe1c9b..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client.gen.ts @@ -11,22 +11,8 @@ import { type ClientOptions as DefaultClientOptions, type Config, createClient, * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ -export type CreateClientConfig = (override?: Config2) => Config2 & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient2(createConfig2({ - baseUrl: 'http://localhost:3000/base' -})); - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig2 = (override?: Config) => Config & T>; - -export const client2 = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' })); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts index 2c34871f1..01f8e2d24 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts index 45e48e977..4dfbf97a8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts index 893e5f52d..df3b287f4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts index 1086c2202..c8e3b0f3f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts index 6c866b7bf..cbbcb26a7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts index 89c7c12b3..84312629c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts @@ -9,7 +9,7 @@ import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class DefaultRequests { +export class DefaultServiceRequests { public export(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -56,7 +56,7 @@ export class DefaultRequests { } } -class ODataControllerRequests { +class ODataControllerServiceRequests { public apiVVersionODataControllerCount(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -67,18 +67,18 @@ class ODataControllerRequests { } } -class VVersionRequests { - oDataController = new ODataControllerRequests(); +class VVersionServiceRequests { + oDataControllerService = new ODataControllerServiceRequests(); } -class ApiRequests { - vVersion = new VVersionRequests(); +class ApiServiceRequests { + vVersionService = new VVersionServiceRequests(); } @Injectable({ providedIn: 'root' }) -export class SimpleRequests { +export class SimpleServiceRequests { public deleteCallWithoutParametersAndResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -141,13 +141,13 @@ export class SimpleRequests { ...options }); } - api = new ApiRequests(); + apiService = new ApiServiceRequests(); } @Injectable({ providedIn: 'root' }) -export class ParametersRequests { +export class ParametersServiceRequests { public deleteFoo(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -197,7 +197,7 @@ export class ParametersRequests { @Injectable({ providedIn: 'root' }) -export class DescriptionsRequests { +export class DescriptionsServiceRequests { public callWithDescriptions(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -211,7 +211,7 @@ export class DescriptionsRequests { @Injectable({ providedIn: 'root' }) -export class DeprecatedRequests { +export class DeprecatedServiceRequests { /** * @deprecated */ @@ -228,7 +228,7 @@ export class DeprecatedRequests { @Injectable({ providedIn: 'root' }) -export class RequestBodyRequests { +export class RequestBodyServiceRequests { public postApiVbyApiVersionRequestBody(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -242,7 +242,7 @@ export class RequestBodyRequests { @Injectable({ providedIn: 'root' }) -export class FormDataRequests { +export class FormDataServiceRequests { public postApiVbyApiVersionFormData(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -256,7 +256,7 @@ export class FormDataRequests { @Injectable({ providedIn: 'root' }) -export class DefaultsRequests { +export class DefaultsServiceRequests { public callWithDefaultParameters(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -288,7 +288,7 @@ export class DefaultsRequests { @Injectable({ providedIn: 'root' }) -export class DuplicateRequests { +export class DuplicateServiceRequests { public duplicateName(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -329,7 +329,7 @@ export class DuplicateRequests { @Injectable({ providedIn: 'root' }) -export class NoContentRequests { +export class NoContentServiceRequests { public callWithNoContentResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -352,7 +352,7 @@ export class NoContentRequests { @Injectable({ providedIn: 'root' }) -export class ResponseRequests { +export class ResponseServiceRequests { public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -393,7 +393,7 @@ export class ResponseRequests { @Injectable({ providedIn: 'root' }) -export class MultipleTags1Requests { +export class MultipleTags1ServiceRequests { public dummyA(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -416,7 +416,7 @@ export class MultipleTags1Requests { @Injectable({ providedIn: 'root' }) -export class MultipleTags2Requests { +export class MultipleTags2ServiceRequests { public dummyA(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -439,7 +439,7 @@ export class MultipleTags2Requests { @Injectable({ providedIn: 'root' }) -export class MultipleTags3Requests { +export class MultipleTags3ServiceRequests { public dummyB(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -453,7 +453,7 @@ export class MultipleTags3Requests { @Injectable({ providedIn: 'root' }) -export class CollectionFormatRequests { +export class CollectionFormatServiceRequests { public collectionFormat(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -467,7 +467,7 @@ export class CollectionFormatRequests { @Injectable({ providedIn: 'root' }) -export class TypesRequests { +export class TypesServiceRequests { public types(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -481,7 +481,7 @@ export class TypesRequests { @Injectable({ providedIn: 'root' }) -export class UploadRequests { +export class UploadServiceRequests { public uploadFile(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -495,7 +495,7 @@ export class UploadRequests { @Injectable({ providedIn: 'root' }) -export class FileResponseRequests { +export class FileResponseServiceRequests { public fileResponse(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -509,7 +509,7 @@ export class FileResponseRequests { @Injectable({ providedIn: 'root' }) -export class ComplexRequests { +export class ComplexServiceRequests { public complexTypes(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -532,7 +532,7 @@ export class ComplexRequests { @Injectable({ providedIn: 'root' }) -export class MultipartRequests { +export class MultipartServiceRequests { public multipartResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -555,7 +555,7 @@ export class MultipartRequests { @Injectable({ providedIn: 'root' }) -export class HeaderRequests { +export class HeaderServiceRequests { public callWithResultFromHeader(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -569,7 +569,7 @@ export class HeaderRequests { @Injectable({ providedIn: 'root' }) -export class ErrorRequests { +export class ErrorServiceRequests { public testErrorCode(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -583,7 +583,7 @@ export class ErrorRequests { @Injectable({ providedIn: 'root' }) -export class NonAsciiÆøåÆøÅöôêÊRequests { +export class NonAsciiÆøåÆøÅöôêÊServiceRequests { public nonAsciiæøåÆøÅöôêÊ字符串(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts index c4b0e6215..bd8a166a2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts @@ -3,157 +3,157 @@ import type { Options } from '../../../sdk.gen'; import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../../types.gen'; import { httpResource } from '@angular/common/http'; -import { DefaultRequests, SimpleRequests, ParametersRequests, DescriptionsRequests, DeprecatedRequests, RequestBodyRequests, FormDataRequests, DefaultsRequests, DuplicateRequests, NoContentRequests, ResponseRequests, MultipleTags1Requests, CollectionFormatRequests, TypesRequests, UploadRequests, FileResponseRequests, ComplexRequests, MultipartRequests, HeaderRequests, ErrorRequests, NonAsciiÆøåÆøÅöôêÊRequests } from './requests.gen'; +import { DefaultServiceRequests, SimpleServiceRequests, ParametersServiceRequests, DescriptionsServiceRequests, DeprecatedServiceRequests, RequestBodyServiceRequests, FormDataServiceRequests, DefaultsServiceRequests, DuplicateServiceRequests, NoContentServiceRequests, ResponseServiceRequests, MultipleTags1ServiceRequests, CollectionFormatServiceRequests, TypesServiceRequests, UploadServiceRequests, FileResponseServiceRequests, ComplexServiceRequests, MultipartServiceRequests, HeaderServiceRequests, ErrorServiceRequests, NonAsciiÆøåÆøÅöôêÊServiceRequests } from './requests.gen'; import { inject, Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class DefaultResources { +export class DefaultServiceResources { public export(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).export(opts) : undefined; + return opts ? inject(DefaultServiceRequests).export(opts) : undefined; }); } public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; }); } public import(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).import(opts) : undefined; + return opts ? inject(DefaultServiceRequests).import(opts) : undefined; }); } public fooWow(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).fooWow(opts) : undefined; + return opts ? inject(DefaultServiceRequests).fooWow(opts) : undefined; }); } public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; + return opts ? inject(DefaultServiceRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; }); } } -class ODataControllerResources { +class ODataControllerServiceResources { public apiVVersionODataControllerCount(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).api.vVersion.oDataController.apiVVersionODataControllerCount(opts) : undefined; + return opts ? inject(SimpleServiceRequests).apiService.vVersionService.oDataControllerService.apiVVersionODataControllerCount(opts) : undefined; }); } } -class VVersionResources { - oDataController = new ODataControllerResources(); +class VVersionServiceResources { + oDataControllerService = new ODataControllerServiceResources(); } -class ApiResources { - vVersion = new VVersionResources(); +class ApiServiceResources { + vVersionService = new VVersionServiceResources(); } @Injectable({ providedIn: 'root' }) -export class SimpleResources { +export class SimpleServiceResources { public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; }); } public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).getCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; }); } public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).headCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; }); } public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; }); } public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; }); } public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).postCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; }); } public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).putCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; }); } - api = new ApiResources(); + apiService = new ApiServiceResources(); } @Injectable({ providedIn: 'root' }) -export class ParametersResources { +export class ParametersServiceResources { public deleteFoo(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).deleteFoo(opts) : undefined; + return opts ? inject(ParametersServiceRequests).deleteFoo(opts) : undefined; }); } public callWithParameters(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).callWithParameters(opts) : undefined; + return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; }); } public callWithWeirdParameterNames(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).callWithWeirdParameterNames(opts) : undefined; + return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; }); } public getCallWithOptionalParam(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).getCallWithOptionalParam(opts) : undefined; + return opts ? inject(ParametersServiceRequests).getCallWithOptionalParam(opts) : undefined; }); } public postCallWithOptionalParam(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).postCallWithOptionalParam(opts) : undefined; + return opts ? inject(ParametersServiceRequests).postCallWithOptionalParam(opts) : undefined; }); } } @@ -161,11 +161,11 @@ export class ParametersResources { @Injectable({ providedIn: 'root' }) -export class DescriptionsResources { +export class DescriptionsServiceResources { public callWithDescriptions(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DescriptionsRequests).callWithDescriptions(opts) : undefined; + return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; }); } } @@ -173,14 +173,14 @@ export class DescriptionsResources { @Injectable({ providedIn: 'root' }) -export class DeprecatedResources { +export class DeprecatedServiceResources { /** * @deprecated */ public deprecatedCall(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DeprecatedRequests).deprecatedCall(opts) : undefined; + return opts ? inject(DeprecatedServiceRequests).deprecatedCall(opts) : undefined; }); } } @@ -188,11 +188,11 @@ export class DeprecatedResources { @Injectable({ providedIn: 'root' }) -export class RequestBodyResources { +export class RequestBodyServiceResources { public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(RequestBodyRequests).postApiVbyApiVersionRequestBody(opts) : undefined; + return opts ? inject(RequestBodyServiceRequests).postApiVbyApiVersionRequestBody(opts) : undefined; }); } } @@ -200,11 +200,11 @@ export class RequestBodyResources { @Injectable({ providedIn: 'root' }) -export class FormDataResources { +export class FormDataServiceResources { public postApiVbyApiVersionFormData(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(FormDataRequests).postApiVbyApiVersionFormData(opts) : undefined; + return opts ? inject(FormDataServiceRequests).postApiVbyApiVersionFormData(opts) : undefined; }); } } @@ -212,25 +212,25 @@ export class FormDataResources { @Injectable({ providedIn: 'root' }) -export class DefaultsResources { +export class DefaultsServiceResources { public callWithDefaultParameters(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callWithDefaultParameters(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; }); } public callWithDefaultOptionalParameters(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callWithDefaultOptionalParameters(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; }); } public callToTestOrderOfParams(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callToTestOrderOfParams(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; }); } } @@ -238,32 +238,32 @@ export class DefaultsResources { @Injectable({ providedIn: 'root' }) -export class DuplicateResources { +export class DuplicateServiceResources { public duplicateName(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; }); } public duplicateName2(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName2(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; }); } public duplicateName3(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName3(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; }); } public duplicateName4(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName4(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; }); } } @@ -271,18 +271,18 @@ export class DuplicateResources { @Injectable({ providedIn: 'root' }) -export class NoContentResources { +export class NoContentServiceResources { public callWithNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NoContentRequests).callWithNoContentResponse(opts) : undefined; + return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; }); } public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; }); } } @@ -290,32 +290,32 @@ export class NoContentResources { @Injectable({ providedIn: 'root' }) -export class ResponseResources { +export class ResponseServiceResources { public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; }); } public callWithResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; }); } public callWithDuplicateResponses(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithDuplicateResponses(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; }); } public callWithResponses(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponses(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; }); } } @@ -323,18 +323,18 @@ export class ResponseResources { @Injectable({ providedIn: 'root' }) -export class MultipleTags1Resources { +export class MultipleTags1ServiceResources { public dummyA(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; }); } public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -342,18 +342,18 @@ export class MultipleTags1Resources { @Injectable({ providedIn: 'root' }) -export class MultipleTags2Resources { +export class MultipleTags2ServiceResources { public dummyA(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; }); } public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -361,11 +361,11 @@ export class MultipleTags2Resources { @Injectable({ providedIn: 'root' }) -export class MultipleTags3Resources { +export class MultipleTags3ServiceResources { public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -373,11 +373,11 @@ export class MultipleTags3Resources { @Injectable({ providedIn: 'root' }) -export class CollectionFormatResources { +export class CollectionFormatServiceResources { public collectionFormat(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(CollectionFormatRequests).collectionFormat(opts) : undefined; + return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; }); } } @@ -385,11 +385,11 @@ export class CollectionFormatResources { @Injectable({ providedIn: 'root' }) -export class TypesResources { +export class TypesServiceResources { public types(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(TypesRequests).types(opts) : undefined; + return opts ? inject(TypesServiceRequests).types(opts) : undefined; }); } } @@ -397,11 +397,11 @@ export class TypesResources { @Injectable({ providedIn: 'root' }) -export class UploadResources { +export class UploadServiceResources { public uploadFile(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(UploadRequests).uploadFile(opts) : undefined; + return opts ? inject(UploadServiceRequests).uploadFile(opts) : undefined; }); } } @@ -409,11 +409,11 @@ export class UploadResources { @Injectable({ providedIn: 'root' }) -export class FileResponseResources { +export class FileResponseServiceResources { public fileResponse(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(FileResponseRequests).fileResponse(opts) : undefined; + return opts ? inject(FileResponseServiceRequests).fileResponse(opts) : undefined; }); } } @@ -421,18 +421,18 @@ export class FileResponseResources { @Injectable({ providedIn: 'root' }) -export class ComplexResources { +export class ComplexServiceResources { public complexTypes(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ComplexRequests).complexTypes(opts) : undefined; + return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; }); } public complexParams(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ComplexRequests).complexParams(opts) : undefined; + return opts ? inject(ComplexServiceRequests).complexParams(opts) : undefined; }); } } @@ -440,18 +440,18 @@ export class ComplexResources { @Injectable({ providedIn: 'root' }) -export class MultipartResources { +export class MultipartServiceResources { public multipartResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipartRequests).multipartResponse(opts) : undefined; + return opts ? inject(MultipartServiceRequests).multipartResponse(opts) : undefined; }); } public multipartRequest(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipartRequests).multipartRequest(opts) : undefined; + return opts ? inject(MultipartServiceRequests).multipartRequest(opts) : undefined; }); } } @@ -459,11 +459,11 @@ export class MultipartResources { @Injectable({ providedIn: 'root' }) -export class HeaderResources { +export class HeaderServiceResources { public callWithResultFromHeader(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(HeaderRequests).callWithResultFromHeader(opts) : undefined; + return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; }); } } @@ -471,11 +471,11 @@ export class HeaderResources { @Injectable({ providedIn: 'root' }) -export class ErrorResources { +export class ErrorServiceResources { public testErrorCode(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ErrorRequests).testErrorCode(opts) : undefined; + return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; }); } } @@ -483,11 +483,11 @@ export class ErrorResources { @Injectable({ providedIn: 'root' }) -export class NonAsciiÆøåÆøÅöôêÊResources { +export class NonAsciiÆøåÆøÅöôêÊServiceResources { public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; }); } @@ -497,7 +497,7 @@ export class NonAsciiÆøåÆøÅöôêÊResources { public putWithFormUrlEncoded(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).putWithFormUrlEncoded(opts) : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).putWithFormUrlEncoded(opts) : undefined; }); } } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts index 2e5fe1c9b..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client.gen.ts @@ -11,22 +11,8 @@ import { type ClientOptions as DefaultClientOptions, type Config, createClient, * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ -export type CreateClientConfig = (override?: Config2) => Config2 & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient2(createConfig2({ - baseUrl: 'http://localhost:3000/base' -})); - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig2 = (override?: Config) => Config & T>; - -export const client2 = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' })); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts index 2e5fe1c9b..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client.gen.ts @@ -11,22 +11,8 @@ import { type ClientOptions as DefaultClientOptions, type Config, createClient, * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ -export type CreateClientConfig = (override?: Config2) => Config2 & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient2(createConfig2({ - baseUrl: 'http://localhost:3000/base' -})); - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig2 = (override?: Config) => Config & T>; - -export const client2 = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' })); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts index 2c34871f1..01f8e2d24 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts index 45e48e977..4dfbf97a8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts index 893e5f52d..df3b287f4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts index 1086c2202..c8e3b0f3f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts index 6c866b7bf..cbbcb26a7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts index 89c7c12b3..84312629c 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts @@ -9,7 +9,7 @@ import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class DefaultRequests { +export class DefaultServiceRequests { public export(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -56,7 +56,7 @@ export class DefaultRequests { } } -class ODataControllerRequests { +class ODataControllerServiceRequests { public apiVVersionODataControllerCount(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -67,18 +67,18 @@ class ODataControllerRequests { } } -class VVersionRequests { - oDataController = new ODataControllerRequests(); +class VVersionServiceRequests { + oDataControllerService = new ODataControllerServiceRequests(); } -class ApiRequests { - vVersion = new VVersionRequests(); +class ApiServiceRequests { + vVersionService = new VVersionServiceRequests(); } @Injectable({ providedIn: 'root' }) -export class SimpleRequests { +export class SimpleServiceRequests { public deleteCallWithoutParametersAndResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -141,13 +141,13 @@ export class SimpleRequests { ...options }); } - api = new ApiRequests(); + apiService = new ApiServiceRequests(); } @Injectable({ providedIn: 'root' }) -export class ParametersRequests { +export class ParametersServiceRequests { public deleteFoo(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -197,7 +197,7 @@ export class ParametersRequests { @Injectable({ providedIn: 'root' }) -export class DescriptionsRequests { +export class DescriptionsServiceRequests { public callWithDescriptions(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -211,7 +211,7 @@ export class DescriptionsRequests { @Injectable({ providedIn: 'root' }) -export class DeprecatedRequests { +export class DeprecatedServiceRequests { /** * @deprecated */ @@ -228,7 +228,7 @@ export class DeprecatedRequests { @Injectable({ providedIn: 'root' }) -export class RequestBodyRequests { +export class RequestBodyServiceRequests { public postApiVbyApiVersionRequestBody(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -242,7 +242,7 @@ export class RequestBodyRequests { @Injectable({ providedIn: 'root' }) -export class FormDataRequests { +export class FormDataServiceRequests { public postApiVbyApiVersionFormData(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -256,7 +256,7 @@ export class FormDataRequests { @Injectable({ providedIn: 'root' }) -export class DefaultsRequests { +export class DefaultsServiceRequests { public callWithDefaultParameters(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -288,7 +288,7 @@ export class DefaultsRequests { @Injectable({ providedIn: 'root' }) -export class DuplicateRequests { +export class DuplicateServiceRequests { public duplicateName(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -329,7 +329,7 @@ export class DuplicateRequests { @Injectable({ providedIn: 'root' }) -export class NoContentRequests { +export class NoContentServiceRequests { public callWithNoContentResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -352,7 +352,7 @@ export class NoContentRequests { @Injectable({ providedIn: 'root' }) -export class ResponseRequests { +export class ResponseServiceRequests { public callWithResponseAndNoContentResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -393,7 +393,7 @@ export class ResponseRequests { @Injectable({ providedIn: 'root' }) -export class MultipleTags1Requests { +export class MultipleTags1ServiceRequests { public dummyA(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -416,7 +416,7 @@ export class MultipleTags1Requests { @Injectable({ providedIn: 'root' }) -export class MultipleTags2Requests { +export class MultipleTags2ServiceRequests { public dummyA(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -439,7 +439,7 @@ export class MultipleTags2Requests { @Injectable({ providedIn: 'root' }) -export class MultipleTags3Requests { +export class MultipleTags3ServiceRequests { public dummyB(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -453,7 +453,7 @@ export class MultipleTags3Requests { @Injectable({ providedIn: 'root' }) -export class CollectionFormatRequests { +export class CollectionFormatServiceRequests { public collectionFormat(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -467,7 +467,7 @@ export class CollectionFormatRequests { @Injectable({ providedIn: 'root' }) -export class TypesRequests { +export class TypesServiceRequests { public types(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -481,7 +481,7 @@ export class TypesRequests { @Injectable({ providedIn: 'root' }) -export class UploadRequests { +export class UploadServiceRequests { public uploadFile(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -495,7 +495,7 @@ export class UploadRequests { @Injectable({ providedIn: 'root' }) -export class FileResponseRequests { +export class FileResponseServiceRequests { public fileResponse(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -509,7 +509,7 @@ export class FileResponseRequests { @Injectable({ providedIn: 'root' }) -export class ComplexRequests { +export class ComplexServiceRequests { public complexTypes(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -532,7 +532,7 @@ export class ComplexRequests { @Injectable({ providedIn: 'root' }) -export class MultipartRequests { +export class MultipartServiceRequests { public multipartResponse(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -555,7 +555,7 @@ export class MultipartRequests { @Injectable({ providedIn: 'root' }) -export class HeaderRequests { +export class HeaderServiceRequests { public callWithResultFromHeader(options?: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -569,7 +569,7 @@ export class HeaderRequests { @Injectable({ providedIn: 'root' }) -export class ErrorRequests { +export class ErrorServiceRequests { public testErrorCode(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', @@ -583,7 +583,7 @@ export class ErrorRequests { @Injectable({ providedIn: 'root' }) -export class NonAsciiÆøåÆøÅöôêÊRequests { +export class NonAsciiÆøåÆøÅöôêÊServiceRequests { public nonAsciiæøåÆøÅöôêÊ字符串(options: Options): HttpRequest { return (options?.client ?? client).requestOptions({ responseStyle: 'data', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts index c4b0e6215..bd8a166a2 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts @@ -3,157 +3,157 @@ import type { Options } from '../../../sdk.gen'; import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3 as DeleteFooData, CallWithDescriptionsData, DeprecatedCallData, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, PostCallWithOptionalParamResponse, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseData, CallWithResponseAndNoContentResponseResponse, DummyAData, DummyAResponse, DummyBData, DummyBResponse, CallWithResponseData, CallWithResponseResponse, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithResponsesData, CallWithResponsesResponse, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../../../types.gen'; import { httpResource } from '@angular/common/http'; -import { DefaultRequests, SimpleRequests, ParametersRequests, DescriptionsRequests, DeprecatedRequests, RequestBodyRequests, FormDataRequests, DefaultsRequests, DuplicateRequests, NoContentRequests, ResponseRequests, MultipleTags1Requests, CollectionFormatRequests, TypesRequests, UploadRequests, FileResponseRequests, ComplexRequests, MultipartRequests, HeaderRequests, ErrorRequests, NonAsciiÆøåÆøÅöôêÊRequests } from './requests.gen'; +import { DefaultServiceRequests, SimpleServiceRequests, ParametersServiceRequests, DescriptionsServiceRequests, DeprecatedServiceRequests, RequestBodyServiceRequests, FormDataServiceRequests, DefaultsServiceRequests, DuplicateServiceRequests, NoContentServiceRequests, ResponseServiceRequests, MultipleTags1ServiceRequests, CollectionFormatServiceRequests, TypesServiceRequests, UploadServiceRequests, FileResponseServiceRequests, ComplexServiceRequests, MultipartServiceRequests, HeaderServiceRequests, ErrorServiceRequests, NonAsciiÆøåÆøÅöôêÊServiceRequests } from './requests.gen'; import { inject, Injectable } from '@angular/core'; @Injectable({ providedIn: 'root' }) -export class DefaultResources { +export class DefaultServiceResources { public export(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).export(opts) : undefined; + return opts ? inject(DefaultServiceRequests).export(opts) : undefined; }); } public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; }); } public import(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).import(opts) : undefined; + return opts ? inject(DefaultServiceRequests).import(opts) : undefined; }); } public fooWow(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).fooWow(opts) : undefined; + return opts ? inject(DefaultServiceRequests).fooWow(opts) : undefined; }); } public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; + return opts ? inject(DefaultServiceRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; }); } } -class ODataControllerResources { +class ODataControllerServiceResources { public apiVVersionODataControllerCount(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).api.vVersion.oDataController.apiVVersionODataControllerCount(opts) : undefined; + return opts ? inject(SimpleServiceRequests).apiService.vVersionService.oDataControllerService.apiVVersionODataControllerCount(opts) : undefined; }); } } -class VVersionResources { - oDataController = new ODataControllerResources(); +class VVersionServiceResources { + oDataControllerService = new ODataControllerServiceResources(); } -class ApiResources { - vVersion = new VVersionResources(); +class ApiServiceResources { + vVersionService = new VVersionServiceResources(); } @Injectable({ providedIn: 'root' }) -export class SimpleResources { +export class SimpleServiceResources { public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; }); } public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).getCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; }); } public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).headCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; }); } public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; }); } public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; }); } public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).postCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; }); } public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(SimpleRequests).putCallWithoutParametersAndResponse(opts) : undefined; + return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; }); } - api = new ApiResources(); + apiService = new ApiServiceResources(); } @Injectable({ providedIn: 'root' }) -export class ParametersResources { +export class ParametersServiceResources { public deleteFoo(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).deleteFoo(opts) : undefined; + return opts ? inject(ParametersServiceRequests).deleteFoo(opts) : undefined; }); } public callWithParameters(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).callWithParameters(opts) : undefined; + return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; }); } public callWithWeirdParameterNames(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).callWithWeirdParameterNames(opts) : undefined; + return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; }); } public getCallWithOptionalParam(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).getCallWithOptionalParam(opts) : undefined; + return opts ? inject(ParametersServiceRequests).getCallWithOptionalParam(opts) : undefined; }); } public postCallWithOptionalParam(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ParametersRequests).postCallWithOptionalParam(opts) : undefined; + return opts ? inject(ParametersServiceRequests).postCallWithOptionalParam(opts) : undefined; }); } } @@ -161,11 +161,11 @@ export class ParametersResources { @Injectable({ providedIn: 'root' }) -export class DescriptionsResources { +export class DescriptionsServiceResources { public callWithDescriptions(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DescriptionsRequests).callWithDescriptions(opts) : undefined; + return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; }); } } @@ -173,14 +173,14 @@ export class DescriptionsResources { @Injectable({ providedIn: 'root' }) -export class DeprecatedResources { +export class DeprecatedServiceResources { /** * @deprecated */ public deprecatedCall(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DeprecatedRequests).deprecatedCall(opts) : undefined; + return opts ? inject(DeprecatedServiceRequests).deprecatedCall(opts) : undefined; }); } } @@ -188,11 +188,11 @@ export class DeprecatedResources { @Injectable({ providedIn: 'root' }) -export class RequestBodyResources { +export class RequestBodyServiceResources { public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(RequestBodyRequests).postApiVbyApiVersionRequestBody(opts) : undefined; + return opts ? inject(RequestBodyServiceRequests).postApiVbyApiVersionRequestBody(opts) : undefined; }); } } @@ -200,11 +200,11 @@ export class RequestBodyResources { @Injectable({ providedIn: 'root' }) -export class FormDataResources { +export class FormDataServiceResources { public postApiVbyApiVersionFormData(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(FormDataRequests).postApiVbyApiVersionFormData(opts) : undefined; + return opts ? inject(FormDataServiceRequests).postApiVbyApiVersionFormData(opts) : undefined; }); } } @@ -212,25 +212,25 @@ export class FormDataResources { @Injectable({ providedIn: 'root' }) -export class DefaultsResources { +export class DefaultsServiceResources { public callWithDefaultParameters(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callWithDefaultParameters(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; }); } public callWithDefaultOptionalParameters(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callWithDefaultOptionalParameters(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; }); } public callToTestOrderOfParams(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DefaultsRequests).callToTestOrderOfParams(opts) : undefined; + return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; }); } } @@ -238,32 +238,32 @@ export class DefaultsResources { @Injectable({ providedIn: 'root' }) -export class DuplicateResources { +export class DuplicateServiceResources { public duplicateName(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; }); } public duplicateName2(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName2(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; }); } public duplicateName3(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName3(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; }); } public duplicateName4(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(DuplicateRequests).duplicateName4(opts) : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; }); } } @@ -271,18 +271,18 @@ export class DuplicateResources { @Injectable({ providedIn: 'root' }) -export class NoContentResources { +export class NoContentServiceResources { public callWithNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NoContentRequests).callWithNoContentResponse(opts) : undefined; + return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; }); } public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; }); } } @@ -290,32 +290,32 @@ export class NoContentResources { @Injectable({ providedIn: 'root' }) -export class ResponseResources { +export class ResponseServiceResources { public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponseAndNoContentResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; }); } public callWithResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponse(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; }); } public callWithDuplicateResponses(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithDuplicateResponses(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; }); } public callWithResponses(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ResponseRequests).callWithResponses(opts) : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; }); } } @@ -323,18 +323,18 @@ export class ResponseResources { @Injectable({ providedIn: 'root' }) -export class MultipleTags1Resources { +export class MultipleTags1ServiceResources { public dummyA(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; }); } public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -342,18 +342,18 @@ export class MultipleTags1Resources { @Injectable({ providedIn: 'root' }) -export class MultipleTags2Resources { +export class MultipleTags2ServiceResources { public dummyA(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyA(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; }); } public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -361,11 +361,11 @@ export class MultipleTags2Resources { @Injectable({ providedIn: 'root' }) -export class MultipleTags3Resources { +export class MultipleTags3ServiceResources { public dummyB(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1Requests).dummyB(opts) : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; }); } } @@ -373,11 +373,11 @@ export class MultipleTags3Resources { @Injectable({ providedIn: 'root' }) -export class CollectionFormatResources { +export class CollectionFormatServiceResources { public collectionFormat(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(CollectionFormatRequests).collectionFormat(opts) : undefined; + return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; }); } } @@ -385,11 +385,11 @@ export class CollectionFormatResources { @Injectable({ providedIn: 'root' }) -export class TypesResources { +export class TypesServiceResources { public types(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(TypesRequests).types(opts) : undefined; + return opts ? inject(TypesServiceRequests).types(opts) : undefined; }); } } @@ -397,11 +397,11 @@ export class TypesResources { @Injectable({ providedIn: 'root' }) -export class UploadResources { +export class UploadServiceResources { public uploadFile(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(UploadRequests).uploadFile(opts) : undefined; + return opts ? inject(UploadServiceRequests).uploadFile(opts) : undefined; }); } } @@ -409,11 +409,11 @@ export class UploadResources { @Injectable({ providedIn: 'root' }) -export class FileResponseResources { +export class FileResponseServiceResources { public fileResponse(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(FileResponseRequests).fileResponse(opts) : undefined; + return opts ? inject(FileResponseServiceRequests).fileResponse(opts) : undefined; }); } } @@ -421,18 +421,18 @@ export class FileResponseResources { @Injectable({ providedIn: 'root' }) -export class ComplexResources { +export class ComplexServiceResources { public complexTypes(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ComplexRequests).complexTypes(opts) : undefined; + return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; }); } public complexParams(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ComplexRequests).complexParams(opts) : undefined; + return opts ? inject(ComplexServiceRequests).complexParams(opts) : undefined; }); } } @@ -440,18 +440,18 @@ export class ComplexResources { @Injectable({ providedIn: 'root' }) -export class MultipartResources { +export class MultipartServiceResources { public multipartResponse(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipartRequests).multipartResponse(opts) : undefined; + return opts ? inject(MultipartServiceRequests).multipartResponse(opts) : undefined; }); } public multipartRequest(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(MultipartRequests).multipartRequest(opts) : undefined; + return opts ? inject(MultipartServiceRequests).multipartRequest(opts) : undefined; }); } } @@ -459,11 +459,11 @@ export class MultipartResources { @Injectable({ providedIn: 'root' }) -export class HeaderResources { +export class HeaderServiceResources { public callWithResultFromHeader(options?: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(HeaderRequests).callWithResultFromHeader(opts) : undefined; + return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; }); } } @@ -471,11 +471,11 @@ export class HeaderResources { @Injectable({ providedIn: 'root' }) -export class ErrorResources { +export class ErrorServiceResources { public testErrorCode(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(ErrorRequests).testErrorCode(opts) : undefined; + return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; }); } } @@ -483,11 +483,11 @@ export class ErrorResources { @Injectable({ providedIn: 'root' }) -export class NonAsciiÆøåÆøÅöôêÊResources { +export class NonAsciiÆøåÆøÅöôêÊServiceResources { public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; }); } @@ -497,7 +497,7 @@ export class NonAsciiÆøåÆøÅöôêÊResources { public putWithFormUrlEncoded(options: () => Options | undefined) { return httpResource(() => { const opts = options ? options() : undefined; - return opts ? inject(NonAsciiÆøåÆøÅöôêÊRequests).putWithFormUrlEncoded(opts) : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).putWithFormUrlEncoded(opts) : undefined; }); } } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts index 2e5fe1c9b..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client.gen.ts @@ -11,22 +11,8 @@ import { type ClientOptions as DefaultClientOptions, type Config, createClient, * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ -export type CreateClientConfig = (override?: Config2) => Config2 & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient2(createConfig2({ - baseUrl: 'http://localhost:3000/base' -})); - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig2 = (override?: Config) => Config & T>; - -export const client2 = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' })); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts index 2e5fe1c9b..950198e01 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client.gen.ts @@ -11,22 +11,8 @@ import { type ClientOptions as DefaultClientOptions, type Config, createClient, * `setConfig()`. This is useful for example if you're using Next.js * to ensure your client always has the correct values. */ -export type CreateClientConfig = (override?: Config2) => Config2 & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient2(createConfig2({ - baseUrl: 'http://localhost:3000/base' -})); - -/** - * The `createClientConfig()` function will be called on client initialization - * and the returned object will become the client's initial configuration. - * - * You may want to initialize your client this way instead of calling - * `setConfig()`. This is useful for example if you're using Next.js - * to ensure your client always has the correct values. - */ -export type CreateClientConfig2 = (override?: Config) => Config & T>; - -export const client2 = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' })); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts index 2c34871f1..01f8e2d24 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/@tanstack/angular-query-experimental.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/angular-query-experimental'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts index 45e48e977..4dfbf97a8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/@tanstack/react-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/react-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts index 893e5f52d..df3b287f4 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/@tanstack/solid-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/solid-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts index 1086c2202..c8e3b0f3f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/@tanstack/svelte-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type MutationOptions, type DefaultError } from '@tanstack/svelte-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts index 6c866b7bf..cbbcb26a7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/@tanstack/vue-query.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options } from '../sdk.gen'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; import { queryOptions, type UseMutationOptions, type DefaultError } from '@tanstack/vue-query'; import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; import { client } from '../client.gen'; diff --git a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts index 90a582af6..493b5bb2b 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -38,8 +38,9 @@ export default defineConfig(() => { // 'openai.yaml', // 'full.yaml', // 'opencode.yaml', + 'sdk-instance.yaml', // 'validators-circular-ref-2.yaml', - 'zoom-video-sdk.json', + // 'zoom-video-sdk.json', ), // https://registry.scalar.com/@lubos-heyapi-dev-team/apis/demo-api-scalar-galaxy/latest?format=json // path: 'scalar:@lubos-heyapi-dev-team/demo-api-scalar-galaxy', @@ -169,14 +170,14 @@ export default defineConfig(() => { // }, }, { - // asClass: true, + asClass: true, // auth: false, // classNameBuilder: '{{name}}', // classStructure: 'off', // client: false, // include... // instance: true, - // name: '@hey-api/sdk', + name: '@hey-api/sdk', // operationId: false, // params: 'experiment', // responseStyle: 'data', @@ -209,7 +210,7 @@ export default defineConfig(() => { // mutationOptions: { // name: '{{name}}MO', // }, - // name: '@tanstack/react-query', + name: '@tanstack/react-query', // queryKeys: { // name: '{{name}}QK', // }, diff --git a/packages/openapi-ts-tests/main/test/plugins.test.ts b/packages/openapi-ts-tests/main/test/plugins.test.ts index f2c84dcd1..e3b47cda3 100644 --- a/packages/openapi-ts-tests/main/test/plugins.test.ts +++ b/packages/openapi-ts-tests/main/test/plugins.test.ts @@ -519,10 +519,27 @@ for (const version of versions) { }), description: 'generate Fetch API client with Pinia Colada plugin', }, + { + config: createConfig({ + input: 'sdk-instance.yaml', + output: 'asClass', + plugins: [ + '@pinia/colada', + '@hey-api/client-fetch', + { + asClass: true, + classNameBuilder: '{{name}}Service', + name: '@hey-api/sdk', + }, + ], + }), + description: + 'generate Fetch API client with Pinia Colada plugin using class-based SDKs', + }, { config: createConfig({ output: 'default', - plugins: ['@angular/common'], + plugins: ['@angular/common', '@hey-api/client-angular'], }), description: 'generate Angular requests and resources', }, @@ -539,6 +556,7 @@ for (const version of versions) { }, name: '@angular/common', }, + '@hey-api/client-angular', ], }), description: 'generate Angular requests and resources (class)', diff --git a/packages/openapi-ts/src/generate/__tests__/class.test.ts b/packages/openapi-ts/src/generate/__tests__/class.test.ts index 391fdfcf8..81acd5b79 100644 --- a/packages/openapi-ts/src/generate/__tests__/class.test.ts +++ b/packages/openapi-ts/src/generate/__tests__/class.test.ts @@ -69,6 +69,9 @@ describe('generateLegacyClientClass', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -77,6 +80,9 @@ describe('generateLegacyClientClass', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -86,7 +92,7 @@ describe('generateLegacyClientClass', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/generate/__tests__/core.test.ts b/packages/openapi-ts/src/generate/__tests__/core.test.ts index 289612173..d5ba1f33b 100644 --- a/packages/openapi-ts/src/generate/__tests__/core.test.ts +++ b/packages/openapi-ts/src/generate/__tests__/core.test.ts @@ -84,6 +84,9 @@ describe('generateLegacyCore', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -92,6 +95,9 @@ describe('generateLegacyCore', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -101,7 +107,7 @@ describe('generateLegacyCore', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { @@ -220,6 +226,9 @@ describe('generateLegacyCore', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -228,6 +237,9 @@ describe('generateLegacyCore', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -237,7 +249,7 @@ describe('generateLegacyCore', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { @@ -339,6 +351,9 @@ describe('generateLegacyCore', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -347,6 +362,9 @@ describe('generateLegacyCore', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -356,7 +374,7 @@ describe('generateLegacyCore', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts b/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts index 8789dfa17..801c3f38f 100644 --- a/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts +++ b/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts @@ -68,6 +68,9 @@ describe('generateIndexFile', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -76,6 +79,9 @@ describe('generateIndexFile', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -85,7 +91,7 @@ describe('generateIndexFile', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts b/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts index 0cce0aff1..e822389d9 100644 --- a/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts +++ b/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts @@ -82,6 +82,9 @@ describe('generateLegacyOutput', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -90,6 +93,9 @@ describe('generateLegacyOutput', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -99,7 +105,7 @@ describe('generateLegacyOutput', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/openApi/common/parser/__tests__/type.test.ts b/packages/openapi-ts/src/openApi/common/parser/__tests__/type.test.ts index 37d99f63f..bc2d9426d 100644 --- a/packages/openapi-ts/src/openApi/common/parser/__tests__/type.test.ts +++ b/packages/openapi-ts/src/openApi/common/parser/__tests__/type.test.ts @@ -9,7 +9,7 @@ vi.mock('../../../../utils/config', () => { plugins: { '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.test.ts b/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.test.ts index 3e96e1cc2..dbc8979b3 100644 --- a/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.test.ts +++ b/packages/openapi-ts/src/openApi/v3/parser/__tests__/getModel.test.ts @@ -11,7 +11,7 @@ vi.mock('../../../../utils/config', () => { plugins: { '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts b/packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts index a12d285c5..da6f6864e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/__tests__/schemas.test.ts @@ -72,6 +72,9 @@ describe('generateLegacySchemas', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -80,6 +83,9 @@ describe('generateLegacySchemas', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -89,7 +95,7 @@ describe('generateLegacySchemas', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { @@ -210,6 +216,9 @@ describe('generateLegacySchemas', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', nameBuilder: nameFn, @@ -219,6 +228,9 @@ describe('generateLegacySchemas', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -228,7 +240,7 @@ describe('generateLegacySchemas', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts index 9f7283015..1804b5396 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/__tests__/plugin.test.ts @@ -74,6 +74,9 @@ describe('handlerLegacy', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -82,6 +85,9 @@ describe('handlerLegacy', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { asClass: true, name: '@hey-api/sdk', @@ -92,7 +98,7 @@ describe('handlerLegacy', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { @@ -285,6 +291,9 @@ describe('methodNameBuilder', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -293,6 +302,9 @@ describe('methodNameBuilder', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { asClass: true, name: '@hey-api/sdk', @@ -303,7 +315,7 @@ describe('methodNameBuilder', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { @@ -418,6 +430,9 @@ describe('methodNameBuilder', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -426,6 +441,9 @@ describe('methodNameBuilder', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { asClass: true, methodNameBuilder, @@ -437,7 +455,7 @@ describe('methodNameBuilder', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { @@ -554,6 +572,9 @@ describe('methodNameBuilder', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -562,6 +583,9 @@ describe('methodNameBuilder', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { asClass: false, methodNameBuilder, @@ -573,7 +597,7 @@ describe('methodNameBuilder', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts index ac4656771..547a55dbb 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts @@ -72,6 +72,9 @@ describe('generateLegacyTypes', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -80,6 +83,9 @@ describe('generateLegacyTypes', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -89,7 +95,7 @@ describe('generateLegacyTypes', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts b/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts index 13f78452a..46b7dc1d9 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts @@ -94,14 +94,15 @@ export const handler: PiniaColadaPlugin['Handler'] = ({ plugin }) => { } if (state.hasUsedQueryFn) { - // TODO: make this work with static classes - const symbolFunction = plugin.gen.selectSymbolFirst( - sdkPlugin.api.getSelector('function', operation.id), + const symbolImport = plugin.gen.selectSymbolFirst( + entry + ? sdkPlugin.api.getSelector('class', entry.path[0]) + : sdkPlugin.api.getSelector('function', operation.id), ); - if (symbolFunction) { + if (symbolImport) { f.addImport({ - from: symbolFunction.file, - names: [symbolFunction.placeholder], + from: symbolImport.file, + names: [symbolImport.placeholder], }); } } diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts index aeea10d38..8b0ce9a8e 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts @@ -111,14 +111,15 @@ export const handler: PluginHandler = ({ plugin }) => { } if (state.hasUsedQueryFn) { - // TODO: make this work with static classes - const symbolFunction = plugin.gen.selectSymbolFirst( - sdkPlugin.api.getSelector('function', operation.id), + const symbolImport = plugin.gen.selectSymbolFirst( + entry + ? sdkPlugin.api.getSelector('class', entry.path[0]) + : sdkPlugin.api.getSelector('function', operation.id), ); - if (symbolFunction) { + if (symbolImport) { f.addImport({ - from: symbolFunction.file, - names: [symbolFunction.placeholder], + from: symbolImport.file, + names: [symbolImport.placeholder], }); } } diff --git a/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts b/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts index 0d8f2ddc6..6150639e4 100644 --- a/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts +++ b/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts @@ -67,6 +67,9 @@ describe('registerHandlebarHelpers', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -75,6 +78,9 @@ describe('registerHandlebarHelpers', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -84,7 +90,7 @@ describe('registerHandlebarHelpers', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { @@ -177,6 +183,9 @@ describe('registerHandlebarTemplates', () => { ], plugins: { '@hey-api/schemas': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/schemas', }, @@ -185,6 +194,9 @@ describe('registerHandlebarTemplates', () => { output: '', }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', }, @@ -194,7 +206,7 @@ describe('registerHandlebarTemplates', () => { }, '@hey-api/typescript': { api: { - getId: () => '', + getSelector: () => [], schemaToType: () => ({}) as ts.TypeNode, }, config: { diff --git a/packages/openapi-ts/src/utils/__tests__/parse.test.ts b/packages/openapi-ts/src/utils/__tests__/parse.test.ts index 47ea8e92c..45bea2a94 100644 --- a/packages/openapi-ts/src/utils/__tests__/parse.test.ts +++ b/packages/openapi-ts/src/utils/__tests__/parse.test.ts @@ -55,6 +55,9 @@ describe('operationNameFn', () => { pluginOrder: ['legacy/fetch', '@hey-api/sdk'], plugins: { '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', operationId: true, @@ -82,6 +85,9 @@ describe('operationNameFn', () => { plugins: { ...optionsCommon.plugins, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', operationId: true, @@ -99,6 +105,9 @@ describe('operationNameFn', () => { plugins: { ...optionsCommon.plugins, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', operationId: false, @@ -116,6 +125,9 @@ describe('operationNameFn', () => { pluginOrder: ['@hey-api/client-fetch', '@hey-api/sdk'], plugins: { '@hey-api/client-fetch': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/client-fetch', }, @@ -125,6 +137,9 @@ describe('operationNameFn', () => { tags: ['client'], }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', operationId: true, @@ -142,6 +157,9 @@ describe('operationNameFn', () => { pluginOrder: ['@hey-api/client-fetch', '@hey-api/sdk'], plugins: { '@hey-api/client-fetch': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/client-fetch', }, @@ -151,6 +169,9 @@ describe('operationNameFn', () => { tags: ['client'], }, '@hey-api/sdk': { + api: { + getSelector: () => [], + }, config: { name: '@hey-api/sdk', operationId: false, From f6e3b24ad2c00cf586d205fa43bbed5857640714 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 03:00:43 +0800 Subject: [PATCH 5/5] test: update snapshots --- packages/codegen-core/src/files/file.ts | 8 +- .../colada/asClass/@pinia/colada.gen.ts | 124 +++++++ .../@pinia/colada/asClass/client.gen.ts | 16 + .../colada/asClass/client/client.gen.ts | 268 ++++++++++++++ .../@pinia/colada/asClass/client/index.ts | 25 ++ .../@pinia/colada/asClass/client/types.gen.ts | 268 ++++++++++++++ .../@pinia/colada/asClass/client/utils.gen.ts | 337 ++++++++++++++++++ .../@pinia/colada/asClass/core/auth.gen.ts | 42 +++ .../colada/asClass/core/bodySerializer.gen.ts | 92 +++++ .../@pinia/colada/asClass/core/params.gen.ts | 153 ++++++++ .../colada/asClass/core/pathSerializer.gen.ts | 181 ++++++++++ .../asClass/core/serverSentEvents.gen.ts | 264 ++++++++++++++ .../@pinia/colada/asClass/core/types.gen.ts | 118 ++++++ .../@pinia/colada/asClass/core/utils.gen.ts | 143 ++++++++ .../plugins/@pinia/colada/asClass/index.ts | 4 + .../plugins/@pinia/colada/asClass/sdk.gen.ts | 72 ++++ .../@pinia/colada/asClass/types.gen.ts | 101 ++++++ .../colada/asClass/@pinia/colada.gen.ts | 124 +++++++ .../@pinia/colada/asClass/client.gen.ts | 16 + .../colada/asClass/client/client.gen.ts | 268 ++++++++++++++ .../@pinia/colada/asClass/client/index.ts | 25 ++ .../@pinia/colada/asClass/client/types.gen.ts | 268 ++++++++++++++ .../@pinia/colada/asClass/client/utils.gen.ts | 337 ++++++++++++++++++ .../@pinia/colada/asClass/core/auth.gen.ts | 42 +++ .../colada/asClass/core/bodySerializer.gen.ts | 92 +++++ .../@pinia/colada/asClass/core/params.gen.ts | 153 ++++++++ .../colada/asClass/core/pathSerializer.gen.ts | 181 ++++++++++ .../asClass/core/serverSentEvents.gen.ts | 264 ++++++++++++++ .../@pinia/colada/asClass/core/types.gen.ts | 118 ++++++ .../@pinia/colada/asClass/core/utils.gen.ts | 143 ++++++++ .../plugins/@pinia/colada/asClass/index.ts | 4 + .../plugins/@pinia/colada/asClass/sdk.gen.ts | 72 ++++ .../@pinia/colada/asClass/types.gen.ts | 101 ++++++ .../colada/asClass/@pinia/colada.gen.ts | 124 +++++++ .../@pinia/colada/asClass/client.gen.ts | 16 + .../colada/asClass/client/client.gen.ts | 268 ++++++++++++++ .../@pinia/colada/asClass/client/index.ts | 25 ++ .../@pinia/colada/asClass/client/types.gen.ts | 268 ++++++++++++++ .../@pinia/colada/asClass/client/utils.gen.ts | 337 ++++++++++++++++++ .../@pinia/colada/asClass/core/auth.gen.ts | 42 +++ .../colada/asClass/core/bodySerializer.gen.ts | 92 +++++ .../@pinia/colada/asClass/core/params.gen.ts | 153 ++++++++ .../colada/asClass/core/pathSerializer.gen.ts | 181 ++++++++++ .../asClass/core/serverSentEvents.gen.ts | 264 ++++++++++++++ .../@pinia/colada/asClass/core/types.gen.ts | 118 ++++++ .../@pinia/colada/asClass/core/utils.gen.ts | 143 ++++++++ .../plugins/@pinia/colada/asClass/index.ts | 4 + .../plugins/@pinia/colada/asClass/sdk.gen.ts | 72 ++++ .../@pinia/colada/asClass/types.gen.ts | 101 ++++++ .../main/test/openapi-ts.config.ts | 4 +- .../2.0.x/mini/default/zod.gen.ts | 2 +- .../2.0.x/mini/type-format-zod/zod.gen.ts | 2 +- .../__snapshots__/2.0.x/v3/default/zod.gen.ts | 2 +- .../2.0.x/v3/type-format-zod/zod.gen.ts | 2 +- .../__snapshots__/2.0.x/v4/default/zod.gen.ts | 2 +- .../2.0.x/v4/type-format-zod/zod.gen.ts | 2 +- .../array-items-one-of-length-1/zod.gen.ts | 2 +- .../3.0.x/mini/default/zod.gen.ts | 2 +- .../3.0.x/mini/enum-null/zod.gen.ts | 2 +- .../3.0.x/mini/type-format-zod/zod.gen.ts | 2 +- .../3.0.x/mini/validators/zod.gen.ts | 2 +- .../v3/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.0.x/v3/default/zod.gen.ts | 2 +- .../3.0.x/v3/enum-null/zod.gen.ts | 2 +- .../3.0.x/v3/type-format-zod/zod.gen.ts | 2 +- .../3.0.x/v3/validators/zod.gen.ts | 2 +- .../v4/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.0.x/v4/default/zod.gen.ts | 2 +- .../3.0.x/v4/enum-null/zod.gen.ts | 2 +- .../3.0.x/v4/type-format-zod/zod.gen.ts | 2 +- .../3.0.x/v4/validators/zod.gen.ts | 2 +- .../array-items-one-of-length-1/zod.gen.ts | 2 +- .../3.1.x/mini/default/zod.gen.ts | 2 +- .../3.1.x/mini/enum-null/zod.gen.ts | 2 +- .../3.1.x/mini/schema-const/zod.gen.ts | 2 +- .../3.1.x/mini/type-format-zod/zod.gen.ts | 2 +- .../mini/validators-bigint-min-max/zod.gen.ts | 2 +- .../mini/validators-circular-ref-2/zod.gen.ts | 2 +- .../mini/validators-circular-ref/zod.gen.ts | 2 +- .../3.1.x/mini/validators-dates/zod.gen.ts | 2 +- .../3.1.x/mini/validators-metadata/zod.gen.ts | 2 +- .../3.1.x/mini/validators-types/zod.gen.ts | 2 +- .../mini/validators-union-merge/zod.gen.ts | 2 +- .../3.1.x/mini/validators/zod.gen.ts | 2 +- .../v3/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.1.x/v3/default/zod.gen.ts | 2 +- .../3.1.x/v3/enum-null/zod.gen.ts | 2 +- .../3.1.x/v3/schema-const/zod.gen.ts | 2 +- .../3.1.x/v3/type-format-zod/zod.gen.ts | 2 +- .../v3/validators-bigint-min-max/zod.gen.ts | 2 +- .../v3/validators-circular-ref-2/zod.gen.ts | 2 +- .../v3/validators-circular-ref/zod.gen.ts | 2 +- .../3.1.x/v3/validators-dates/zod.gen.ts | 2 +- .../3.1.x/v3/validators-metadata/zod.gen.ts | 2 +- .../3.1.x/v3/validators-types/zod.gen.ts | 2 +- .../v3/validators-union-merge/zod.gen.ts | 2 +- .../3.1.x/v3/validators/zod.gen.ts | 2 +- .../v4/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.1.x/v4/default/zod.gen.ts | 2 +- .../3.1.x/v4/enum-null/zod.gen.ts | 2 +- .../3.1.x/v4/schema-const/zod.gen.ts | 2 +- .../3.1.x/v4/type-format-zod/zod.gen.ts | 2 +- .../v4/validators-bigint-min-max/zod.gen.ts | 2 +- .../v4/validators-circular-ref-2/zod.gen.ts | 2 +- .../v4/validators-circular-ref/zod.gen.ts | 2 +- .../3.1.x/v4/validators-dates/zod.gen.ts | 2 +- .../3.1.x/v4/validators-metadata/zod.gen.ts | 2 +- .../3.1.x/v4/validators-types/zod.gen.ts | 2 +- .../v4/validators-union-merge/zod.gen.ts | 2 +- .../3.1.x/v4/validators/zod.gen.ts | 2 +- .../2.0.x/mini/default/zod.gen.ts | 2 +- .../2.0.x/mini/type-format-zod/zod.gen.ts | 2 +- .../__snapshots__/2.0.x/v3/default/zod.gen.ts | 2 +- .../2.0.x/v3/type-format-zod/zod.gen.ts | 2 +- .../__snapshots__/2.0.x/v4/default/zod.gen.ts | 2 +- .../2.0.x/v4/type-format-zod/zod.gen.ts | 2 +- .../array-items-one-of-length-1/zod.gen.ts | 2 +- .../3.0.x/mini/default/zod.gen.ts | 2 +- .../3.0.x/mini/enum-null/zod.gen.ts | 2 +- .../3.0.x/mini/type-format-zod/zod.gen.ts | 2 +- .../3.0.x/mini/validators/zod.gen.ts | 2 +- .../v3/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.0.x/v3/default/zod.gen.ts | 2 +- .../3.0.x/v3/enum-null/zod.gen.ts | 2 +- .../3.0.x/v3/type-format-zod/zod.gen.ts | 2 +- .../3.0.x/v3/validators/zod.gen.ts | 2 +- .../v4/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.0.x/v4/default/zod.gen.ts | 2 +- .../3.0.x/v4/enum-null/zod.gen.ts | 2 +- .../3.0.x/v4/type-format-zod/zod.gen.ts | 2 +- .../3.0.x/v4/validators/zod.gen.ts | 2 +- .../array-items-one-of-length-1/zod.gen.ts | 2 +- .../3.1.x/mini/default/zod.gen.ts | 2 +- .../3.1.x/mini/enum-null/zod.gen.ts | 2 +- .../3.1.x/mini/schema-const/zod.gen.ts | 2 +- .../3.1.x/mini/type-format-zod/zod.gen.ts | 2 +- .../mini/validators-bigint-min-max/zod.gen.ts | 2 +- .../mini/validators-circular-ref-2/zod.gen.ts | 2 +- .../mini/validators-circular-ref/zod.gen.ts | 2 +- .../3.1.x/mini/validators-dates/zod.gen.ts | 2 +- .../3.1.x/mini/validators-metadata/zod.gen.ts | 2 +- .../3.1.x/mini/validators-types/zod.gen.ts | 2 +- .../mini/validators-union-merge/zod.gen.ts | 2 +- .../3.1.x/mini/validators/zod.gen.ts | 2 +- .../v3/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.1.x/v3/default/zod.gen.ts | 2 +- .../3.1.x/v3/enum-null/zod.gen.ts | 2 +- .../3.1.x/v3/schema-const/zod.gen.ts | 2 +- .../3.1.x/v3/type-format-zod/zod.gen.ts | 2 +- .../v3/validators-bigint-min-max/zod.gen.ts | 2 +- .../v3/validators-circular-ref-2/zod.gen.ts | 2 +- .../v3/validators-circular-ref/zod.gen.ts | 2 +- .../3.1.x/v3/validators-dates/zod.gen.ts | 2 +- .../3.1.x/v3/validators-metadata/zod.gen.ts | 2 +- .../3.1.x/v3/validators-types/zod.gen.ts | 2 +- .../v3/validators-union-merge/zod.gen.ts | 2 +- .../3.1.x/v3/validators/zod.gen.ts | 2 +- .../v4/array-items-one-of-length-1/zod.gen.ts | 2 +- .../__snapshots__/3.1.x/v4/default/zod.gen.ts | 2 +- .../3.1.x/v4/enum-null/zod.gen.ts | 2 +- .../3.1.x/v4/schema-const/zod.gen.ts | 2 +- .../3.1.x/v4/type-format-zod/zod.gen.ts | 2 +- .../v4/validators-bigint-min-max/zod.gen.ts | 2 +- .../v4/validators-circular-ref-2/zod.gen.ts | 2 +- .../v4/validators-circular-ref/zod.gen.ts | 2 +- .../3.1.x/v4/validators-dates/zod.gen.ts | 2 +- .../3.1.x/v4/validators-metadata/zod.gen.ts | 2 +- .../3.1.x/v4/validators-types/zod.gen.ts | 2 +- .../v4/validators-union-merge/zod.gen.ts | 2 +- .../3.1.x/v4/validators/zod.gen.ts | 2 +- .../openapi-ts/src/plugins/zod/mini/plugin.ts | 5 +- .../openapi-ts/src/plugins/zod/v3/plugin.ts | 4 +- .../openapi-ts/src/plugins/zod/v4/plugin.ts | 4 +- 173 files changed, 6756 insertions(+), 133 deletions(-) create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/auth.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/params.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/utils.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/sdk.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/types.gen.ts diff --git a/packages/codegen-core/src/files/file.ts b/packages/codegen-core/src/files/file.ts index a372f6f3c..36d05a653 100644 --- a/packages/codegen-core/src/files/file.ts +++ b/packages/codegen-core/src/files/file.ts @@ -217,10 +217,12 @@ export class CodegenFile implements ICodegenFile { relativePathToFile(file: Pick): string { let relativePath = path.posix.relative( - path.posix.dirname(this.path), - file.path, + path.posix.dirname( + this.path.split(path.sep).join('/'), // normalize to posix + ), + file.path.split(path.sep).join('/'), // normalize to posix ); - if (!relativePath.startsWith('.')) { + if (!relativePath.startsWith('.') && relativePath !== '') { relativePath = `./${relativePath}`; } return relativePath; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts new file mode 100644 index 000000000..e31c2880d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts @@ -0,0 +1,124 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; +import type { GetFooData, GetFooResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; +import { client } from '../client.gen'; + +export type QueryKey = [ + Pick & { + _id: string; + baseUrl?: _JSONValue; + headers?: _JSONValue; + query?: _JSONValue; + tags?: _JSONValue; + } +]; + +const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ + QueryKey[0] +] => { + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; + if (tags) { + params.tags = tags as unknown as undefined; + } + if (options?.body) { + params.body = options.body; + } + if (options?.headers) { + params.headers = options.headers as unknown as undefined; + } + if (options?.path) { + params.path = options.path; + } + if (options?.query) { + params.query = options.query as unknown as undefined; + } + return [ + params + ]; +}; + +export const getFooQueryKey = (options?: Options) => createQueryKey('getFoo', options); + +export const getFooQuery = (options?: Options): UseQueryOptions => { + return { + key: getFooQueryKey(options), + query: async (context) => { + const { data } = await FooBazService.getFoo({ + ...options, + ...context, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooPostMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.post({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooPutMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.put({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const getFooBarQueryKey = (options?: Options) => createQueryKey('getFooBar', options); + +export const getFooBarQuery = (options?: Options): UseQueryOptions => { + return { + key: getFooBarQueryKey(options), + query: async (context) => { + const { data } = await BarBazService.getFooBar({ + ...options, + ...context, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooBarPostMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.barService.post({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooBarPutMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.barService.put({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client.gen.ts new file mode 100644 index 000000000..fe57f118d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client.gen.ts @@ -0,0 +1,16 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig()); 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 new file mode 100644 index 000000000..6ed36fb89 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Request, + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + const requestInit: ReqInit = { + redirect: 'follow', + ...opts, + body: getValidRequestBody(opts), + }; + + let request = new Request(url, requestInit); + + for (const fn of interceptors.request._fns) { + if (fn) { + request = await fn(request, opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + let response = await _fetch(request); + + for (const fn of interceptors.response._fns) { + if (fn) { + response = await fn(response, request, opts); + } + } + + const result = { + request, + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return opts.responseStyle === 'data' + ? emptyData + : { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return opts.responseStyle === 'data' + ? response.body + : { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return opts.responseStyle === 'data' + ? data + : { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + // TODO: we probably want to return error and improve types + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + for (const fn of interceptors.request._fns) { + if (fn) { + request = await fn(request, opts); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..1a005b51e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Please don't use the Fetch client for Next.js applications. The `next` + * options won't have any effect. + * + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. + */ + next?: never; + /** + * Return the response data parsed in a specified format. By default, `auto` + * will infer the appropriate method from the `Content-Type` response header. + * You can override this behavior with any of the {@link Body} methods. + * Select `stream` if you don't want to parse response data at all. + * + * @default 'auto' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = ThrowOnError extends true + ? Promise< + TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: Request; + response: Response; + } + > + : Promise< + TResponseStyle extends 'data' + ? + | (TData extends Record + ? TData[keyof TData] + : TData) + | undefined + : ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + request: Request; + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts new file mode 100644 index 000000000..b9ec3cdd6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts @@ -0,0 +1,337 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header) { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts new file mode 100644 index 000000000..353557eb6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts @@ -0,0 +1,72 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +class BarService { + public static post(options?: Options) { + return (options?.client ?? client).post({ + url: '/foo/bar', + ...options + }); + } + + public static put(options?: Options) { + return (options?.client ?? client).put({ + url: '/foo/bar', + ...options + }); + } +} + +class FooService { + public static post(options?: Options) { + return (options?.client ?? client).post({ + url: '/foo', + ...options + }); + } + + public static put(options?: Options) { + return (options?.client ?? client).put({ + url: '/foo', + ...options + }); + } + static barService = BarService; +} + +export class FooBazService { + public static getFoo(options?: Options) { + return (options?.client ?? client).get({ + url: '/foo', + ...options + }); + } + static fooService = FooService; +} + +export class BarBazService { + public static getFooBar(options?: Options) { + return (options?.client ?? client).get({ + url: '/foo/bar', + ...options + }); + } + static fooService = FooService; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/types.gen.ts new file mode 100644 index 000000000..28d798a00 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/types.gen.ts @@ -0,0 +1,101 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type GetFooData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type GetFooResponses = { + /** + * OK + */ + 200: string; +}; + +export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; + +export type FooPostData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type FooPostResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooPostResponse = FooPostResponses[keyof FooPostResponses]; + +export type FooPutData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type FooPutResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooPutResponse = FooPutResponses[keyof FooPutResponses]; + +export type GetFooBarData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type GetFooBarResponses = { + /** + * OK + */ + 200: string; +}; + +export type GetFooBarResponse = GetFooBarResponses[keyof GetFooBarResponses]; + +export type FooBarPostData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type FooBarPostResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooBarPostResponse = FooBarPostResponses[keyof FooBarPostResponses]; + +export type FooBarPutData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type FooBarPutResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; + +export type ClientOptions = { + baseUrl: string; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts new file mode 100644 index 000000000..e31c2880d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts @@ -0,0 +1,124 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; +import type { GetFooData, GetFooResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; +import { client } from '../client.gen'; + +export type QueryKey = [ + Pick & { + _id: string; + baseUrl?: _JSONValue; + headers?: _JSONValue; + query?: _JSONValue; + tags?: _JSONValue; + } +]; + +const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ + QueryKey[0] +] => { + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; + if (tags) { + params.tags = tags as unknown as undefined; + } + if (options?.body) { + params.body = options.body; + } + if (options?.headers) { + params.headers = options.headers as unknown as undefined; + } + if (options?.path) { + params.path = options.path; + } + if (options?.query) { + params.query = options.query as unknown as undefined; + } + return [ + params + ]; +}; + +export const getFooQueryKey = (options?: Options) => createQueryKey('getFoo', options); + +export const getFooQuery = (options?: Options): UseQueryOptions => { + return { + key: getFooQueryKey(options), + query: async (context) => { + const { data } = await FooBazService.getFoo({ + ...options, + ...context, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooPostMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.post({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooPutMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.put({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const getFooBarQueryKey = (options?: Options) => createQueryKey('getFooBar', options); + +export const getFooBarQuery = (options?: Options): UseQueryOptions => { + return { + key: getFooBarQueryKey(options), + query: async (context) => { + const { data } = await BarBazService.getFooBar({ + ...options, + ...context, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooBarPostMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.barService.post({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooBarPutMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.barService.put({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client.gen.ts new file mode 100644 index 000000000..fe57f118d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client.gen.ts @@ -0,0 +1,16 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig()); 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 new file mode 100644 index 000000000..6ed36fb89 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Request, + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + const requestInit: ReqInit = { + redirect: 'follow', + ...opts, + body: getValidRequestBody(opts), + }; + + let request = new Request(url, requestInit); + + for (const fn of interceptors.request._fns) { + if (fn) { + request = await fn(request, opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + let response = await _fetch(request); + + for (const fn of interceptors.response._fns) { + if (fn) { + response = await fn(response, request, opts); + } + } + + const result = { + request, + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return opts.responseStyle === 'data' + ? emptyData + : { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return opts.responseStyle === 'data' + ? response.body + : { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return opts.responseStyle === 'data' + ? data + : { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + // TODO: we probably want to return error and improve types + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + for (const fn of interceptors.request._fns) { + if (fn) { + request = await fn(request, opts); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..1a005b51e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/types.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Please don't use the Fetch client for Next.js applications. The `next` + * options won't have any effect. + * + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. + */ + next?: never; + /** + * Return the response data parsed in a specified format. By default, `auto` + * will infer the appropriate method from the `Content-Type` response header. + * You can override this behavior with any of the {@link Body} methods. + * Select `stream` if you don't want to parse response data at all. + * + * @default 'auto' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = ThrowOnError extends true + ? Promise< + TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: Request; + response: Response; + } + > + : Promise< + TResponseStyle extends 'data' + ? + | (TData extends Record + ? TData[keyof TData] + : TData) + | undefined + : ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + request: Request; + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts new file mode 100644 index 000000000..b9ec3cdd6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/utils.gen.ts @@ -0,0 +1,337 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header) { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts new file mode 100644 index 000000000..353557eb6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/sdk.gen.ts @@ -0,0 +1,72 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +class BarService { + public static post(options?: Options) { + return (options?.client ?? client).post({ + url: '/foo/bar', + ...options + }); + } + + public static put(options?: Options) { + return (options?.client ?? client).put({ + url: '/foo/bar', + ...options + }); + } +} + +class FooService { + public static post(options?: Options) { + return (options?.client ?? client).post({ + url: '/foo', + ...options + }); + } + + public static put(options?: Options) { + return (options?.client ?? client).put({ + url: '/foo', + ...options + }); + } + static barService = BarService; +} + +export class FooBazService { + public static getFoo(options?: Options) { + return (options?.client ?? client).get({ + url: '/foo', + ...options + }); + } + static fooService = FooService; +} + +export class BarBazService { + public static getFooBar(options?: Options) { + return (options?.client ?? client).get({ + url: '/foo/bar', + ...options + }); + } + static fooService = FooService; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/types.gen.ts new file mode 100644 index 000000000..4001df3e9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/types.gen.ts @@ -0,0 +1,101 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type GetFooData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type GetFooResponses = { + /** + * OK + */ + 200: string; +}; + +export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; + +export type FooPostData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type FooPostResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooPostResponse = FooPostResponses[keyof FooPostResponses]; + +export type FooPutData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type FooPutResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooPutResponse = FooPutResponses[keyof FooPutResponses]; + +export type GetFooBarData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type GetFooBarResponses = { + /** + * OK + */ + 200: string; +}; + +export type GetFooBarResponse = GetFooBarResponses[keyof GetFooBarResponses]; + +export type FooBarPostData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type FooBarPostResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooBarPostResponse = FooBarPostResponses[keyof FooBarPostResponses]; + +export type FooBarPutData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type FooBarPutResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; + +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts new file mode 100644 index 000000000..e31c2880d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/@pinia/colada.gen.ts @@ -0,0 +1,124 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { _JSONValue, UseQueryOptions, UseMutationOptions } from '@pinia/colada'; +import type { GetFooData, GetFooResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; +import { client } from '../client.gen'; + +export type QueryKey = [ + Pick & { + _id: string; + baseUrl?: _JSONValue; + headers?: _JSONValue; + query?: _JSONValue; + tags?: _JSONValue; + } +]; + +const createQueryKey = (id: string, options?: TOptions, tags?: ReadonlyArray): [ + QueryKey[0] +] => { + const params: QueryKey[0] = { _id: id, baseUrl: options?.baseUrl || (options?.client ?? client).getConfig().baseUrl } as QueryKey[0]; + if (tags) { + params.tags = tags as unknown as undefined; + } + if (options?.body) { + params.body = options.body; + } + if (options?.headers) { + params.headers = options.headers as unknown as undefined; + } + if (options?.path) { + params.path = options.path; + } + if (options?.query) { + params.query = options.query as unknown as undefined; + } + return [ + params + ]; +}; + +export const getFooQueryKey = (options?: Options) => createQueryKey('getFoo', options); + +export const getFooQuery = (options?: Options): UseQueryOptions => { + return { + key: getFooQueryKey(options), + query: async (context) => { + const { data } = await FooBazService.getFoo({ + ...options, + ...context, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooPostMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.post({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooPutMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.put({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const getFooBarQueryKey = (options?: Options) => createQueryKey('getFooBar', options); + +export const getFooBarQuery = (options?: Options): UseQueryOptions => { + return { + key: getFooBarQueryKey(options), + query: async (context) => { + const { data } = await BarBazService.getFooBar({ + ...options, + ...context, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooBarPostMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.barService.post({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; + +export const fooBarPutMutation = (options?: Partial>): UseMutationOptions, Error> => { + return { + mutation: async (fnOptions) => { + const { data } = await FooBazService.fooService.barService.put({ + ...options, + ...fnOptions, + throwOnError: true + }); + return data; + } + }; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client.gen.ts new file mode 100644 index 000000000..fe57f118d --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client.gen.ts @@ -0,0 +1,16 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { ClientOptions } from './types.gen'; +import { type ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = (override?: Config) => Config & T>; + +export const client = createClient(createConfig()); 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 new file mode 100644 index 000000000..6ed36fb89 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { createSseClient } from '../core/serverSentEvents.gen'; +import type { HttpMethod } from '../core/types.gen'; +import { getValidRequestBody } from '../core/utils.gen'; +import type { + Client, + Config, + RequestOptions, + ResolvedRequestOptions, +} from './types.gen'; +import { + buildUrl, + createConfig, + createInterceptors, + getParseAs, + mergeConfigs, + mergeHeaders, + setAuthParams, +} from './utils.gen'; + +type ReqInit = Omit & { + body?: any; + headers: ReturnType; +}; + +export const createClient = (config: Config = {}): Client => { + let _config = mergeConfigs(createConfig(), config); + + const getConfig = (): Config => ({ ..._config }); + + const setConfig = (config: Config): Config => { + _config = mergeConfigs(_config, config); + return getConfig(); + }; + + const interceptors = createInterceptors< + Request, + Response, + unknown, + ResolvedRequestOptions + >(); + + const beforeRequest = async (options: RequestOptions) => { + const opts = { + ..._config, + ...options, + fetch: options.fetch ?? _config.fetch ?? globalThis.fetch, + headers: mergeHeaders(_config.headers, options.headers), + serializedBody: undefined, + }; + + if (opts.security) { + await setAuthParams({ + ...opts, + security: opts.security, + }); + } + + if (opts.requestValidator) { + await opts.requestValidator(opts); + } + + if (opts.body !== undefined && opts.bodySerializer) { + opts.serializedBody = opts.bodySerializer(opts.body); + } + + // remove Content-Type header if body is empty to avoid sending invalid requests + if (opts.body === undefined || opts.serializedBody === '') { + opts.headers.delete('Content-Type'); + } + + const url = buildUrl(opts); + + return { opts, url }; + }; + + const request: Client['request'] = async (options) => { + // @ts-expect-error + const { opts, url } = await beforeRequest(options); + const requestInit: ReqInit = { + redirect: 'follow', + ...opts, + body: getValidRequestBody(opts), + }; + + let request = new Request(url, requestInit); + + for (const fn of interceptors.request._fns) { + if (fn) { + request = await fn(request, opts); + } + } + + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = opts.fetch!; + let response = await _fetch(request); + + for (const fn of interceptors.response._fns) { + if (fn) { + response = await fn(response, request, opts); + } + } + + const result = { + request, + response, + }; + + if (response.ok) { + const parseAs = + (opts.parseAs === 'auto' + ? getParseAs(response.headers.get('Content-Type')) + : opts.parseAs) ?? 'json'; + + if ( + response.status === 204 || + response.headers.get('Content-Length') === '0' + ) { + let emptyData: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'text': + emptyData = await response[parseAs](); + break; + case 'formData': + emptyData = new FormData(); + break; + case 'stream': + emptyData = response.body; + break; + case 'json': + default: + emptyData = {}; + break; + } + return opts.responseStyle === 'data' + ? emptyData + : { + data: emptyData, + ...result, + }; + } + + let data: any; + switch (parseAs) { + case 'arrayBuffer': + case 'blob': + case 'formData': + case 'json': + case 'text': + data = await response[parseAs](); + break; + case 'stream': + return opts.responseStyle === 'data' + ? response.body + : { + data: response.body, + ...result, + }; + } + + if (parseAs === 'json') { + if (opts.responseValidator) { + await opts.responseValidator(data); + } + + if (opts.responseTransformer) { + data = await opts.responseTransformer(data); + } + } + + return opts.responseStyle === 'data' + ? data + : { + data, + ...result, + }; + } + + const textError = await response.text(); + let jsonError: unknown; + + try { + jsonError = JSON.parse(textError); + } catch { + // noop + } + + const error = jsonError ?? textError; + let finalError = error; + + for (const fn of interceptors.error._fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } + } + + finalError = finalError || ({} as string); + + if (opts.throwOnError) { + throw finalError; + } + + // TODO: we probably want to return error and improve types + return opts.responseStyle === 'data' + ? undefined + : { + error: finalError, + ...result, + }; + }; + + const makeMethodFn = + (method: Uppercase) => (options: RequestOptions) => + request({ ...options, method }); + + const makeSseFn = + (method: Uppercase) => async (options: RequestOptions) => { + const { opts, url } = await beforeRequest(options); + return createSseClient({ + ...opts, + body: opts.body as BodyInit | null | undefined, + headers: opts.headers as unknown as Record, + method, + onRequest: async (url, init) => { + let request = new Request(url, init); + for (const fn of interceptors.request._fns) { + if (fn) { + request = await fn(request, opts); + } + } + return request; + }, + url, + }); + }; + + return { + buildUrl, + connect: makeMethodFn('CONNECT'), + delete: makeMethodFn('DELETE'), + get: makeMethodFn('GET'), + getConfig, + head: makeMethodFn('HEAD'), + interceptors, + options: makeMethodFn('OPTIONS'), + patch: makeMethodFn('PATCH'), + post: makeMethodFn('POST'), + put: makeMethodFn('PUT'), + request, + setConfig, + sse: { + connect: makeSseFn('CONNECT'), + delete: makeSseFn('DELETE'), + get: makeSseFn('GET'), + head: makeSseFn('HEAD'), + options: makeSseFn('OPTIONS'), + patch: makeSseFn('PATCH'), + post: makeSseFn('POST'), + put: makeSseFn('PUT'), + trace: makeSseFn('TRACE'), + }, + trace: makeMethodFn('TRACE'), + } as Client; +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/index.ts new file mode 100644 index 000000000..318a84b6a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/index.ts @@ -0,0 +1,25 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type { Auth } from '../core/auth.gen'; +export type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +export { + formDataBodySerializer, + jsonBodySerializer, + urlSearchParamsBodySerializer, +} from '../core/bodySerializer.gen'; +export { buildClientParams } from '../core/params.gen'; +export { createClient } from './client.gen'; +export type { + Client, + ClientOptions, + Config, + CreateClientConfig, + Options, + OptionsLegacyParser, + RequestOptions, + RequestResult, + ResolvedRequestOptions, + ResponseStyle, + TDataShape, +} from './types.gen'; +export { createConfig, mergeHeaders } from './utils.gen'; 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 new file mode 100644 index 000000000..1a005b51e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/types.gen.ts @@ -0,0 +1,268 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth } from '../core/auth.gen'; +import type { + ServerSentEventsOptions, + ServerSentEventsResult, +} from '../core/serverSentEvents.gen'; +import type { + Client as CoreClient, + Config as CoreConfig, +} from '../core/types.gen'; +import type { Middleware } from './utils.gen'; + +export type ResponseStyle = 'data' | 'fields'; + +export interface Config + extends Omit, + CoreConfig { + /** + * Base URL for all requests made by this client. + */ + baseUrl?: T['baseUrl']; + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Please don't use the Fetch client for Next.js applications. The `next` + * options won't have any effect. + * + * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead. + */ + next?: never; + /** + * Return the response data parsed in a specified format. By default, `auto` + * will infer the appropriate method from the `Content-Type` response header. + * You can override this behavior with any of the {@link Body} methods. + * Select `stream` if you don't want to parse response data at all. + * + * @default 'auto' + */ + parseAs?: + | 'arrayBuffer' + | 'auto' + | 'blob' + | 'formData' + | 'json' + | 'stream' + | 'text'; + /** + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: ResponseStyle; + /** + * Throw an error instead of returning it in the response? + * + * @default false + */ + throwOnError?: T['throwOnError']; +} + +export interface RequestOptions< + TData = unknown, + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends Config<{ + responseStyle: TResponseStyle; + throwOnError: ThrowOnError; + }>, + Pick< + ServerSentEventsOptions, + | 'onSseError' + | 'onSseEvent' + | 'sseDefaultRetryDelay' + | 'sseMaxRetryAttempts' + | 'sseMaxRetryDelay' + > { + /** + * Any body that you want to add to your request. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#body} + */ + body?: unknown; + path?: Record; + query?: Record; + /** + * Security mechanism(s) to use for the request. + */ + security?: ReadonlyArray; + url: Url; +} + +export interface ResolvedRequestOptions< + TResponseStyle extends ResponseStyle = 'fields', + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + serializedBody?: string; +} + +export type RequestResult< + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = ThrowOnError extends true + ? Promise< + TResponseStyle extends 'data' + ? TData extends Record + ? TData[keyof TData] + : TData + : { + data: TData extends Record + ? TData[keyof TData] + : TData; + request: Request; + response: Response; + } + > + : Promise< + TResponseStyle extends 'data' + ? + | (TData extends Record + ? TData[keyof TData] + : TData) + | undefined + : ( + | { + data: TData extends Record + ? TData[keyof TData] + : TData; + error: undefined; + } + | { + data: undefined; + error: TError extends Record + ? TError[keyof TError] + : TError; + } + ) & { + request: Request; + response: Response; + } + >; + +export interface ClientOptions { + baseUrl?: string; + responseStyle?: ResponseStyle; + throwOnError?: boolean; +} + +type MethodFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => RequestResult; + +type SseFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'>, +) => Promise>; + +type RequestFn = < + TData = unknown, + TError = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', +>( + options: Omit, 'method'> & + Pick< + Required>, + 'method' + >, +) => RequestResult; + +type BuildUrlFn = < + TData extends { + body?: unknown; + path?: Record; + query?: Record; + url: string; + }, +>( + options: Pick & Options, +) => string; + +export type Client = CoreClient< + RequestFn, + Config, + MethodFn, + BuildUrlFn, + SseFn +> & { + interceptors: Middleware; +}; + +/** + * The `createClientConfig()` function will be called on client initialization + * and the returned object will become the client's initial configuration. + * + * You may want to initialize your client this way instead of calling + * `setConfig()`. This is useful for example if you're using Next.js + * to ensure your client always has the correct values. + */ +export type CreateClientConfig = ( + override?: Config, +) => Config & T>; + +export interface TDataShape { + body?: unknown; + headers?: unknown; + path?: unknown; + query?: unknown; + url: string; +} + +type OmitKeys = Pick>; + +export type Options< + TData extends TDataShape = TDataShape, + ThrowOnError extends boolean = boolean, + TResponse = unknown, + TResponseStyle extends ResponseStyle = 'fields', +> = OmitKeys< + RequestOptions, + 'body' | 'path' | 'query' | 'url' +> & + Omit; + +export type OptionsLegacyParser< + TData = unknown, + ThrowOnError extends boolean = boolean, + TResponseStyle extends ResponseStyle = 'fields', +> = TData extends { body?: any } + ? TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'body' | 'headers' | 'url' + > & + TData + : OmitKeys< + RequestOptions, + 'body' | 'url' + > & + TData & + Pick, 'headers'> + : TData extends { headers?: any } + ? OmitKeys< + RequestOptions, + 'headers' | 'url' + > & + TData & + Pick, 'body'> + : OmitKeys, 'url'> & + TData; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/utils.gen.ts new file mode 100644 index 000000000..b9ec3cdd6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/utils.gen.ts @@ -0,0 +1,337 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { getAuthToken } from '../core/auth.gen'; +import type { QuerySerializerOptions } from '../core/bodySerializer.gen'; +import { jsonBodySerializer } from '../core/bodySerializer.gen'; +import { + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from '../core/pathSerializer.gen'; +import { getUrl } from '../core/utils.gen'; +import type { Client, ClientOptions, Config, RequestOptions } from './types.gen'; + +export const createQuerySerializer = ({ + allowReserved, + array, + object, +}: QuerySerializerOptions = {}) => { + const querySerializer = (queryParams: T) => { + const search: string[] = []; + if (queryParams && typeof queryParams === 'object') { + for (const name in queryParams) { + const value = queryParams[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + const serializedArray = serializeArrayParam({ + allowReserved, + explode: true, + name, + style: 'form', + value, + ...array, + }); + if (serializedArray) search.push(serializedArray); + } else if (typeof value === 'object') { + const serializedObject = serializeObjectParam({ + allowReserved, + explode: true, + name, + style: 'deepObject', + value: value as Record, + ...object, + }); + if (serializedObject) search.push(serializedObject); + } else { + const serializedPrimitive = serializePrimitiveParam({ + allowReserved, + name, + value: value as string, + }); + if (serializedPrimitive) search.push(serializedPrimitive); + } + } + } + return search.join('&'); + }; + return querySerializer; +}; + +/** + * Infers parseAs value from provided Content-Type header. + */ +export const getParseAs = ( + contentType: string | null, +): Exclude => { + if (!contentType) { + // If no Content-Type header is provided, the best we can do is return the raw response body, + // which is effectively the same as the 'stream' option. + return 'stream'; + } + + const cleanContent = contentType.split(';')[0]?.trim(); + + if (!cleanContent) { + return; + } + + if ( + cleanContent.startsWith('application/json') || + cleanContent.endsWith('+json') + ) { + return 'json'; + } + + if (cleanContent === 'multipart/form-data') { + return 'formData'; + } + + if ( + ['application/', 'audio/', 'image/', 'video/'].some((type) => + cleanContent.startsWith(type), + ) + ) { + return 'blob'; + } + + if (cleanContent.startsWith('text/')) { + return 'text'; + } + + return; +}; + +const checkForExistence = ( + options: Pick & { + headers: Headers; + }, + name?: string, +): boolean => { + if (!name) { + return false; + } + if ( + options.headers.has(name) || + options.query?.[name] || + options.headers.get('Cookie')?.includes(`${name}=`) + ) { + return true; + } + return false; +}; + +export const setAuthParams = async ({ + security, + ...options +}: Pick, 'security'> & + Pick & { + headers: Headers; + }) => { + for (const auth of security) { + if (checkForExistence(options, auth.name)) { + continue; + } + + const token = await getAuthToken(auth, options.auth); + + if (!token) { + continue; + } + + const name = auth.name ?? 'Authorization'; + + switch (auth.in) { + case 'query': + if (!options.query) { + options.query = {}; + } + options.query[name] = token; + break; + case 'cookie': + options.headers.append('Cookie', `${name}=${token}`); + break; + case 'header': + default: + options.headers.set(name, token); + break; + } + } +}; + +export const buildUrl: Client['buildUrl'] = (options) => + getUrl({ + baseUrl: options.baseUrl as string, + path: options.path, + query: options.query, + querySerializer: + typeof options.querySerializer === 'function' + ? options.querySerializer + : createQuerySerializer(options.querySerializer), + url: options.url, + }); + +export const mergeConfigs = (a: Config, b: Config): Config => { + const config = { ...a, ...b }; + if (config.baseUrl?.endsWith('/')) { + config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1); + } + config.headers = mergeHeaders(a.headers, b.headers); + return config; +}; + +const headersEntries = (headers: Headers): Array<[string, string]> => { + const entries: Array<[string, string]> = []; + headers.forEach((value, key) => { + entries.push([key, value]); + }); + return entries; +}; + +export const mergeHeaders = ( + ...headers: Array['headers'] | undefined> +): Headers => { + const mergedHeaders = new Headers(); + for (const header of headers) { + if (!header) { + continue; + } + + const iterator = + header instanceof Headers + ? headersEntries(header) + : Object.entries(header); + + for (const [key, value] of iterator) { + if (value === null) { + mergedHeaders.delete(key); + } else if (Array.isArray(value)) { + for (const v of value) { + mergedHeaders.append(key, v as string); + } + } else if (value !== undefined) { + // assume object headers are meant to be JSON stringified, i.e. their + // content value in OpenAPI specification is 'application/json' + mergedHeaders.set( + key, + typeof value === 'object' ? JSON.stringify(value) : (value as string), + ); + } + } + } + return mergedHeaders; +}; + +type ErrInterceptor = ( + error: Err, + response: Res, + request: Req, + options: Options, +) => Err | Promise; + +type ReqInterceptor = ( + request: Req, + options: Options, +) => Req | Promise; + +type ResInterceptor = ( + response: Res, + request: Req, + options: Options, +) => Res | Promise; + +class Interceptors { + _fns: (Interceptor | null)[]; + + constructor() { + this._fns = []; + } + + clear() { + this._fns = []; + } + + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this._fns[id] ? id : -1; + } else { + return this._fns.indexOf(id); + } + } + exists(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + return !!this._fns[index]; + } + + eject(id: number | Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = null; + } + } + + update(id: number | Interceptor, fn: Interceptor) { + const index = this.getInterceptorIndex(id); + if (this._fns[index]) { + this._fns[index] = fn; + return id; + } else { + return false; + } + } + + use(fn: Interceptor) { + this._fns = [...this._fns, fn]; + return this._fns.length - 1; + } +} + +// `createInterceptors()` response, meant for external use as it does not +// expose internals +export interface Middleware { + error: Pick< + Interceptors>, + 'eject' | 'use' + >; + request: Pick>, 'eject' | 'use'>; + response: Pick< + Interceptors>, + 'eject' | 'use' + >; +} + +// do not add `Middleware` as return type so we can use _fns internally +export const createInterceptors = () => ({ + error: new Interceptors>(), + request: new Interceptors>(), + response: new Interceptors>(), +}); + +const defaultQuerySerializer = createQuerySerializer({ + allowReserved: false, + array: { + explode: true, + style: 'form', + }, + object: { + explode: true, + style: 'deepObject', + }, +}); + +const defaultHeaders = { + 'Content-Type': 'application/json', +}; + +export const createConfig = ( + override: Config & T> = {}, +): Config & T> => ({ + ...jsonBodySerializer, + headers: defaultHeaders, + parseAs: 'auto', + querySerializer: defaultQuerySerializer, + ...override, +}); 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 new file mode 100644 index 000000000..f8a73266f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/auth.gen.ts @@ -0,0 +1,42 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type AuthToken = string | undefined; + +export interface Auth { + /** + * Which part of the request do we use to send the auth? + * + * @default 'header' + */ + in?: 'header' | 'query' | 'cookie'; + /** + * Header or query parameter name. + * + * @default 'Authorization' + */ + name?: string; + scheme?: 'basic' | 'bearer'; + type: 'apiKey' | 'http'; +} + +export const getAuthToken = async ( + auth: Auth, + callback: ((auth: Auth) => Promise | AuthToken) | AuthToken, +): Promise => { + const token = + typeof callback === 'function' ? await callback(auth) : callback; + + if (!token) { + return; + } + + if (auth.scheme === 'bearer') { + return `Bearer ${token}`; + } + + if (auth.scheme === 'basic') { + return `Basic ${btoa(token)}`; + } + + return token; +}; 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 new file mode 100644 index 000000000..49cd8925e --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/bodySerializer.gen.ts @@ -0,0 +1,92 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { + ArrayStyle, + ObjectStyle, + SerializerOptions, +} from './pathSerializer.gen'; + +export type QuerySerializer = (query: Record) => string; + +export type BodySerializer = (body: any) => any; + +export interface QuerySerializerOptions { + allowReserved?: boolean; + array?: SerializerOptions; + object?: SerializerOptions; +} + +const serializeFormDataPair = ( + data: FormData, + key: string, + value: unknown, +): void => { + if (typeof value === 'string' || value instanceof Blob) { + data.append(key, value); + } else if (value instanceof Date) { + data.append(key, value.toISOString()); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +const serializeUrlSearchParamsPair = ( + data: URLSearchParams, + key: string, + value: unknown, +): void => { + if (typeof value === 'string') { + data.append(key, value); + } else { + data.append(key, JSON.stringify(value)); + } +}; + +export const formDataBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): FormData => { + const data = new FormData(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeFormDataPair(data, key, v)); + } else { + serializeFormDataPair(data, key, value); + } + }); + + return data; + }, +}; + +export const jsonBodySerializer = { + bodySerializer: (body: T): string => + JSON.stringify(body, (_key, value) => + typeof value === 'bigint' ? value.toString() : value, + ), +}; + +export const urlSearchParamsBodySerializer = { + bodySerializer: | Array>>( + body: T, + ): string => { + const data = new URLSearchParams(); + + Object.entries(body).forEach(([key, value]) => { + if (value === undefined || value === null) { + return; + } + if (Array.isArray(value)) { + value.forEach((v) => serializeUrlSearchParamsPair(data, key, v)); + } else { + serializeUrlSearchParamsPair(data, key, value); + } + }); + + return data.toString(); + }, +}; 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 new file mode 100644 index 000000000..71c88e852 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/params.gen.ts @@ -0,0 +1,153 @@ +// This file is auto-generated by @hey-api/openapi-ts + +type Slot = 'body' | 'headers' | 'path' | 'query'; + +export type Field = + | { + in: Exclude; + /** + * Field name. This is the name we want the user to see and use. + */ + key: string; + /** + * 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; + } + | { + in: Extract; + /** + * Key isn't required for bodies. + */ + key?: string; + map?: string; + }; + +export interface Fields { + allowExtra?: Partial>; + args?: ReadonlyArray; +} + +export type FieldsConfig = ReadonlyArray; + +const extraPrefixesMap: Record = { + $body_: 'body', + $headers_: 'headers', + $path_: 'path', + $query_: 'query', +}; +const extraPrefixes = Object.entries(extraPrefixesMap); + +type KeyMap = Map< + string, + { + in: Slot; + map?: string; + } +>; + +const buildKeyMap = (fields: FieldsConfig, map?: KeyMap): KeyMap => { + if (!map) { + map = new Map(); + } + + for (const config of fields) { + if ('in' in config) { + if (config.key) { + map.set(config.key, { + in: config.in, + map: config.map, + }); + } + } else if (config.args) { + buildKeyMap(config.args, map); + } + } + + return map; +}; + +interface Params { + body: unknown; + headers: Record; + path: Record; + query: Record; +} + +const stripEmptySlots = (params: Params) => { + for (const [slot, value] of Object.entries(params)) { + if (value && typeof value === 'object' && !Object.keys(value).length) { + delete params[slot as Slot]; + } + } +}; + +export const buildClientParams = ( + args: ReadonlyArray, + fields: FieldsConfig, +) => { + const params: Params = { + body: {}, + headers: {}, + path: {}, + query: {}, + }; + + const map = buildKeyMap(fields); + + let config: FieldsConfig[number] | undefined; + + for (const [index, arg] of args.entries()) { + if (fields[index]) { + config = fields[index]; + } + + if (!config) { + continue; + } + + if ('in' in config) { + if (config.key) { + const field = map.get(config.key)!; + const name = field.map || config.key; + (params[field.in] as Record)[name] = arg; + } else { + params.body = arg; + } + } else { + for (const [key, value] of Object.entries(arg ?? {})) { + const field = map.get(key); + + if (field) { + const name = field.map || key; + (params[field.in] as Record)[name] = value; + } else { + const extra = extraPrefixes.find(([prefix]) => + key.startsWith(prefix), + ); + + if (extra) { + const [prefix, slot] = extra; + (params[slot] as Record)[ + key.slice(prefix.length) + ] = value; + } else { + for (const [slot, allowed] of Object.entries( + config.allowExtra ?? {}, + )) { + if (allowed) { + (params[slot as Slot] as Record)[key] = value; + break; + } + } + } + } + } + } + } + + stripEmptySlots(params); + + return params; +}; 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 new file mode 100644 index 000000000..8d9993104 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/pathSerializer.gen.ts @@ -0,0 +1,181 @@ +// This file is auto-generated by @hey-api/openapi-ts + +interface SerializeOptions + extends SerializePrimitiveOptions, + SerializerOptions {} + +interface SerializePrimitiveOptions { + allowReserved?: boolean; + name: string; +} + +export interface SerializerOptions { + /** + * @default true + */ + explode: boolean; + style: T; +} + +export type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited'; +export type ArraySeparatorStyle = ArrayStyle | MatrixStyle; +type MatrixStyle = 'label' | 'matrix' | 'simple'; +export type ObjectStyle = 'form' | 'deepObject'; +type ObjectSeparatorStyle = ObjectStyle | MatrixStyle; + +interface SerializePrimitiveParam extends SerializePrimitiveOptions { + value: string; +} + +export const separatorArrayExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const separatorArrayNoExplode = (style: ArraySeparatorStyle) => { + switch (style) { + case 'form': + return ','; + case 'pipeDelimited': + return '|'; + case 'spaceDelimited': + return '%20'; + default: + return ','; + } +}; + +export const separatorObjectExplode = (style: ObjectSeparatorStyle) => { + switch (style) { + case 'label': + return '.'; + case 'matrix': + return ';'; + case 'simple': + return ','; + default: + return '&'; + } +}; + +export const serializeArrayParam = ({ + allowReserved, + explode, + name, + style, + value, +}: SerializeOptions & { + value: unknown[]; +}) => { + if (!explode) { + const joinedValues = ( + allowReserved ? value : value.map((v) => encodeURIComponent(v as string)) + ).join(separatorArrayNoExplode(style)); + switch (style) { + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + case 'simple': + return joinedValues; + default: + return `${name}=${joinedValues}`; + } + } + + const separator = separatorArrayExplode(style); + const joinedValues = value + .map((v) => { + if (style === 'label' || style === 'simple') { + return allowReserved ? v : encodeURIComponent(v as string); + } + + return serializePrimitiveParam({ + allowReserved, + name, + value: v as string, + }); + }) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; + +export const serializePrimitiveParam = ({ + allowReserved, + name, + value, +}: SerializePrimitiveParam) => { + if (value === undefined || value === null) { + return ''; + } + + if (typeof value === 'object') { + throw new Error( + 'Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.', + ); + } + + return `${name}=${allowReserved ? value : encodeURIComponent(value)}`; +}; + +export const serializeObjectParam = ({ + allowReserved, + explode, + name, + style, + value, + valueOnly, +}: SerializeOptions & { + value: Record | Date; + valueOnly?: boolean; +}) => { + if (value instanceof Date) { + return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`; + } + + if (style !== 'deepObject' && !explode) { + let values: string[] = []; + Object.entries(value).forEach(([key, v]) => { + values = [ + ...values, + key, + allowReserved ? (v as string) : encodeURIComponent(v as string), + ]; + }); + const joinedValues = values.join(','); + switch (style) { + case 'form': + return `${name}=${joinedValues}`; + case 'label': + return `.${joinedValues}`; + case 'matrix': + return `;${name}=${joinedValues}`; + default: + return joinedValues; + } + } + + const separator = separatorObjectExplode(style); + const joinedValues = Object.entries(value) + .map(([key, v]) => + serializePrimitiveParam({ + allowReserved, + name: style === 'deepObject' ? `${name}[${key}]` : key, + value: v as string, + }), + ) + .join(separator); + return style === 'label' || style === 'matrix' + ? separator + joinedValues + : joinedValues; +}; 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 new file mode 100644 index 000000000..f8fd78e28 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/serverSentEvents.gen.ts @@ -0,0 +1,264 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Config } from './types.gen'; + +export type ServerSentEventsOptions = Omit< + RequestInit, + 'method' +> & + Pick & { + /** + * Fetch API implementation. You can use this option to provide a custom + * fetch instance. + * + * @default globalThis.fetch + */ + fetch?: typeof fetch; + /** + * Implementing clients can call request interceptors inside this hook. + */ + onRequest?: (url: string, init: RequestInit) => Promise; + /** + * Callback invoked when a network or parsing error occurs during streaming. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param error The error that occurred. + */ + onSseError?: (error: unknown) => void; + /** + * Callback invoked when an event is streamed from the server. + * + * This option applies only if the endpoint returns a stream of events. + * + * @param event Event streamed from the server. + * @returns Nothing (void). + */ + onSseEvent?: (event: StreamEvent) => void; + serializedBody?: RequestInit['body']; + /** + * Default retry delay in milliseconds. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 3000 + */ + sseDefaultRetryDelay?: number; + /** + * Maximum number of retry attempts before giving up. + */ + sseMaxRetryAttempts?: number; + /** + * Maximum retry delay in milliseconds. + * + * Applies only when exponential backoff is used. + * + * This option applies only if the endpoint returns a stream of events. + * + * @default 30000 + */ + sseMaxRetryDelay?: number; + /** + * Optional sleep function for retry backoff. + * + * Defaults to using `setTimeout`. + */ + sseSleepFn?: (ms: number) => Promise; + url: string; + }; + +export interface StreamEvent { + data: TData; + event?: string; + id?: string; + retry?: number; +} + +export type ServerSentEventsResult< + TData = unknown, + TReturn = void, + TNext = unknown, +> = { + stream: AsyncGenerator< + TData extends Record ? TData[keyof TData] : TData, + TReturn, + TNext + >; +}; + +export const createSseClient = ({ + onRequest, + onSseError, + onSseEvent, + responseTransformer, + responseValidator, + sseDefaultRetryDelay, + sseMaxRetryAttempts, + sseMaxRetryDelay, + sseSleepFn, + url, + ...options +}: ServerSentEventsOptions): ServerSentEventsResult => { + let lastEventId: string | undefined; + + const sleep = + sseSleepFn ?? + ((ms: number) => new Promise((resolve) => setTimeout(resolve, ms))); + + const createStream = async function* () { + let retryDelay: number = sseDefaultRetryDelay ?? 3000; + let attempt = 0; + const signal = options.signal ?? new AbortController().signal; + + while (true) { + if (signal.aborted) break; + + attempt++; + + const headers = + options.headers instanceof Headers + ? options.headers + : new Headers(options.headers as Record | undefined); + + if (lastEventId !== undefined) { + headers.set('Last-Event-ID', lastEventId); + } + + try { + const requestInit: RequestInit = { + redirect: 'follow', + ...options, + body: options.serializedBody, + headers, + signal, + }; + let request = new Request(url, requestInit); + if (onRequest) { + request = await onRequest(url, requestInit); + } + // fetch must be assigned here, otherwise it would throw the error: + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation + const _fetch = options.fetch ?? globalThis.fetch; + const response = await _fetch(request); + + if (!response.ok) + throw new Error( + `SSE failed: ${response.status} ${response.statusText}`, + ); + + if (!response.body) throw new Error('No body in SSE response'); + + const reader = response.body + .pipeThrough(new TextDecoderStream()) + .getReader(); + + let buffer = ''; + + const abortHandler = () => { + try { + reader.cancel(); + } catch { + // noop + } + }; + + signal.addEventListener('abort', abortHandler); + + try { + while (true) { + const { done, value } = await reader.read(); + if (done) break; + buffer += value; + + const chunks = buffer.split('\n\n'); + buffer = chunks.pop() ?? ''; + + for (const chunk of chunks) { + const lines = chunk.split('\n'); + const dataLines: Array = []; + let eventName: string | undefined; + + for (const line of lines) { + if (line.startsWith('data:')) { + dataLines.push(line.replace(/^data:\s*/, '')); + } else if (line.startsWith('event:')) { + eventName = line.replace(/^event:\s*/, ''); + } else if (line.startsWith('id:')) { + lastEventId = line.replace(/^id:\s*/, ''); + } else if (line.startsWith('retry:')) { + const parsed = Number.parseInt( + line.replace(/^retry:\s*/, ''), + 10, + ); + if (!Number.isNaN(parsed)) { + retryDelay = parsed; + } + } + } + + let data: unknown; + let parsedJson = false; + + if (dataLines.length) { + const rawData = dataLines.join('\n'); + try { + data = JSON.parse(rawData); + parsedJson = true; + } catch { + data = rawData; + } + } + + if (parsedJson) { + if (responseValidator) { + await responseValidator(data); + } + + if (responseTransformer) { + data = await responseTransformer(data); + } + } + + onSseEvent?.({ + data, + event: eventName, + id: lastEventId, + retry: retryDelay, + }); + + if (dataLines.length) { + yield data as any; + } + } + } + } finally { + signal.removeEventListener('abort', abortHandler); + reader.releaseLock(); + } + + break; // exit loop on normal completion + } catch (error) { + // connection failed or aborted; retry after delay + onSseError?.(error); + + if ( + sseMaxRetryAttempts !== undefined && + attempt >= sseMaxRetryAttempts + ) { + break; // stop after firing error + } + + // exponential backoff: double retry each attempt, cap at 30s + const backoff = Math.min( + retryDelay * 2 ** (attempt - 1), + sseMaxRetryDelay ?? 30000, + ); + await sleep(backoff); + } + } + }; + + const stream = createStream(); + + return { stream }; +}; 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 new file mode 100644 index 000000000..643c070c9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/types.gen.ts @@ -0,0 +1,118 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Auth, AuthToken } from './auth.gen'; +import type { + BodySerializer, + QuerySerializer, + QuerySerializerOptions, +} from './bodySerializer.gen'; + +export type HttpMethod = + | 'connect' + | 'delete' + | 'get' + | 'head' + | 'options' + | 'patch' + | 'post' + | 'put' + | 'trace'; + +export type Client< + RequestFn = never, + Config = unknown, + MethodFn = never, + BuildUrlFn = never, + SseFn = never, +> = { + /** + * Returns the final request URL. + */ + buildUrl: BuildUrlFn; + getConfig: () => Config; + request: RequestFn; + setConfig: (config: Config) => Config; +} & { + [K in HttpMethod]: MethodFn; +} & ([SseFn] extends [never] + ? { sse?: never } + : { sse: { [K in HttpMethod]: SseFn } }); + +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; + /** + * A function for serializing request body parameter. By default, + * {@link JSON.stringify()} will be used. + */ + bodySerializer?: BodySerializer | null; + /** + * An object containing any HTTP headers that you want to pre-populate your + * `Headers` object with. + * + * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more} + */ + headers?: + | RequestInit['headers'] + | Record< + string, + | string + | number + | boolean + | (string | number | boolean)[] + | null + | undefined + | unknown + >; + /** + * The request method. + * + * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more} + */ + method?: Uppercase; + /** + * A function for serializing request query parameters. By default, arrays + * will be exploded in form style, objects will be exploded in deepObject + * style, and reserved characters are percent-encoded. + * + * This method will have no effect if the native `paramsSerializer()` Axios + * API function is used. + * + * {@link https://swagger.io/docs/specification/serialization/#query View examples} + */ + querySerializer?: QuerySerializer | QuerySerializerOptions; + /** + * 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; + /** + * 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; + /** + * 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; +} + +type IsExactlyNeverOrNeverUndefined = [T] extends [never] + ? true + : [T] extends [never | undefined] + ? [undefined] extends [T] + ? false + : true + : false; + +export type OmitNever> = { + [K in keyof T as IsExactlyNeverOrNeverUndefined extends true + ? never + : K]: T[K]; +}; 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 new file mode 100644 index 000000000..0b5389d08 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/core/utils.gen.ts @@ -0,0 +1,143 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { BodySerializer, QuerySerializer } from './bodySerializer.gen'; +import { + type ArraySeparatorStyle, + serializeArrayParam, + serializeObjectParam, + serializePrimitiveParam, +} from './pathSerializer.gen'; + +export interface PathSerializer { + path: Record; + url: string; +} + +export const PATH_PARAM_RE = /\{[^{}]+\}/g; + +export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => { + let url = _url; + const matches = _url.match(PATH_PARAM_RE); + if (matches) { + for (const match of matches) { + let explode = false; + let name = match.substring(1, match.length - 1); + let style: ArraySeparatorStyle = 'simple'; + + if (name.endsWith('*')) { + explode = true; + name = name.substring(0, name.length - 1); + } + + if (name.startsWith('.')) { + name = name.substring(1); + style = 'label'; + } else if (name.startsWith(';')) { + name = name.substring(1); + style = 'matrix'; + } + + const value = path[name]; + + if (value === undefined || value === null) { + continue; + } + + if (Array.isArray(value)) { + url = url.replace( + match, + serializeArrayParam({ explode, name, style, value }), + ); + continue; + } + + if (typeof value === 'object') { + url = url.replace( + match, + serializeObjectParam({ + explode, + name, + style, + value: value as Record, + valueOnly: true, + }), + ); + continue; + } + + if (style === 'matrix') { + url = url.replace( + match, + `;${serializePrimitiveParam({ + name, + value: value as string, + })}`, + ); + continue; + } + + const replaceValue = encodeURIComponent( + style === 'label' ? `.${value as string}` : (value as string), + ); + url = url.replace(match, replaceValue); + } + } + return url; +}; + +export const getUrl = ({ + baseUrl, + path, + query, + querySerializer, + url: _url, +}: { + baseUrl?: string; + path?: Record; + query?: Record; + querySerializer: QuerySerializer; + url: string; +}) => { + const pathUrl = _url.startsWith('/') ? _url : `/${_url}`; + let url = (baseUrl ?? '') + pathUrl; + if (path) { + url = defaultPathSerializer({ path, url }); + } + let search = query ? querySerializer(query) : ''; + if (search.startsWith('?')) { + search = search.substring(1); + } + if (search) { + url += `?${search}`; + } + return url; +}; + +export function getValidRequestBody(options: { + body?: unknown; + bodySerializer?: BodySerializer | null; + serializedBody?: unknown; +}) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + if ('serializedBody' in options) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // not all clients implement a serializedBody property (i.e. client-axios) + return options.body !== '' ? options.body : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + // no body was provided + return undefined; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/index.ts new file mode 100644 index 000000000..cc646f13a --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/index.ts @@ -0,0 +1,4 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; +export * from './sdk.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/sdk.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/sdk.gen.ts new file mode 100644 index 000000000..353557eb6 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/sdk.gen.ts @@ -0,0 +1,72 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; +import { client } from './client.gen'; + +export type Options = ClientOptions & { + /** + * You can provide a client instance returned by `createClient()` instead of + * individual options. This might be also useful if you want to implement a + * custom client. + */ + client?: Client; + /** + * You can pass arbitrary values through the `meta` object. This can be + * used to access values that aren't defined as part of the SDK function. + */ + meta?: Record; +}; + +class BarService { + public static post(options?: Options) { + return (options?.client ?? client).post({ + url: '/foo/bar', + ...options + }); + } + + public static put(options?: Options) { + return (options?.client ?? client).put({ + url: '/foo/bar', + ...options + }); + } +} + +class FooService { + public static post(options?: Options) { + return (options?.client ?? client).post({ + url: '/foo', + ...options + }); + } + + public static put(options?: Options) { + return (options?.client ?? client).put({ + url: '/foo', + ...options + }); + } + static barService = BarService; +} + +export class FooBazService { + public static getFoo(options?: Options) { + return (options?.client ?? client).get({ + url: '/foo', + ...options + }); + } + static fooService = FooService; +} + +export class BarBazService { + public static getFooBar(options?: Options) { + return (options?.client ?? client).get({ + url: '/foo/bar', + ...options + }); + } + static fooService = FooService; +} diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/types.gen.ts new file mode 100644 index 000000000..4001df3e9 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/types.gen.ts @@ -0,0 +1,101 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type GetFooData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type GetFooResponses = { + /** + * OK + */ + 200: string; +}; + +export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; + +export type FooPostData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type FooPostResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooPostResponse = FooPostResponses[keyof FooPostResponses]; + +export type FooPutData = { + body?: never; + path?: never; + query?: never; + url: '/foo'; +}; + +export type FooPutResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooPutResponse = FooPutResponses[keyof FooPutResponses]; + +export type GetFooBarData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type GetFooBarResponses = { + /** + * OK + */ + 200: string; +}; + +export type GetFooBarResponse = GetFooBarResponses[keyof GetFooBarResponses]; + +export type FooBarPostData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type FooBarPostResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooBarPostResponse = FooBarPostResponses[keyof FooBarPostResponses]; + +export type FooBarPutData = { + body?: never; + path?: never; + query?: never; + url: '/foo/bar'; +}; + +export type FooBarPutResponses = { + /** + * OK + */ + 200: string; +}; + +export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; + +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts index 493b5bb2b..3c31fd029 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -252,7 +252,7 @@ export default defineConfig(() => { { // case: 'snake_case', // comments: false, - compatibilityVersion: 4, + compatibilityVersion: 'mini', dates: { local: true, // offset: true, @@ -265,7 +265,7 @@ export default defineConfig(() => { }, exportFromIndex: true, metadata: true, - // name: 'zod', + name: 'zod', // requests: { // // case: 'SCREAMING_SNAKE_CASE', // // name: 'z{{name}}TestData', diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts index fac119ef0..5b3da321f 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts @@ -780,4 +780,4 @@ export const zPostApiVbyApiVersionBodyData = z.object({ /** * OK */ -export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; \ No newline at end of file +export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts index 213b0f395..79baa0efd 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts index 199445536..e7ba45f19 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts @@ -778,4 +778,4 @@ export const zPostApiVbyApiVersionBodyData = z.object({ /** * OK */ -export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; \ No newline at end of file +export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts index 5b3c0c45c..bcca2e71b 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts index bd11e0d9e..34f491c6f 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts @@ -780,4 +780,4 @@ export const zPostApiVbyApiVersionBodyData = z.object({ /** * OK */ -export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; \ No newline at end of file +export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts index b79373215..c0a77c99d 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts index c0dc11ed2..dc123685e 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts index 94712ccd0..cc4bc0b80 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts @@ -1771,4 +1771,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts index 7071dca84..4cd376b5f 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts index 213b0f395..79baa0efd 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/validators/zod.gen.ts index 22eb864db..a8be5f51c 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/validators/zod.gen.ts @@ -22,4 +22,4 @@ export const zFoo = z._default(z.union([ z.null() ]), null); -export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); \ No newline at end of file +export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts index 91997b20b..e9ac7e7aa 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.array(zBar).min(1).max(2147483647).optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts index fa93133da..c65ab143e 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts @@ -1769,4 +1769,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts index 2b8373603..941cd87ea 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts index 5b3c0c45c..bcca2e71b 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/validators/zod.gen.ts index f4142d499..a6537a847 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/validators/zod.gen.ts @@ -20,4 +20,4 @@ export const zFoo: z.ZodTypeAny = z.union([ z.null() ]).default(null); -export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); \ No newline at end of file +export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts index ea9d76fb3..5f2eda424 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).min(1).max(2147483647)) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts index 5a6d90834..e7d8d2646 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts @@ -1771,4 +1771,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts index ac6994702..8ebbc33b6 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts index b79373215..c0a77c99d 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/validators/zod.gen.ts index 78e8ede96..d0fb4e7a8 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/validators/zod.gen.ts @@ -22,4 +22,4 @@ export const zFoo = z.union([ z.null() ]).default(null); -export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); \ No newline at end of file +export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts index c0dc11ed2..dc123685e 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts index f292838d9..068645092 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts @@ -1787,4 +1787,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts index 7071dca84..4cd376b5f 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts index 851d8b08e..10480c6a6 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts @@ -34,4 +34,4 @@ export const zFoo = z.object({ integerUint64: z.optional(z.int()), stringInt64: z.optional(z.literal('-9223372036854775808')), stringUint64: z.optional(z.literal('18446744073709551615')) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts index 213b0f395..79baa0efd 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts index 62a1267c7..a413f0991 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts @@ -4,4 +4,4 @@ import * as z from 'zod/v4-mini'; export const zFoo = z.object({ foo: z.optional(z.coerce.bigint().check(z.gte(BigInt(0)), z.lte(BigInt(100)))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts index 03b6520c0..967a23660 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts @@ -13,4 +13,4 @@ export const zBar = z.object({ export const zFoo = z.object({ foo: zBar -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts index afe3dfe33..5fa9cefc1 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts @@ -21,4 +21,4 @@ export const zQux = z.lazy((): any => { return zQux; }); -export const zBaz = zQux; \ No newline at end of file +export const zBaz = zQux; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts index c205b93fa..3fd3ebc43 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts @@ -65,4 +65,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts index 25c8c7d32..1a5edf41c 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts @@ -75,4 +75,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts index d3893c43c..a3170d6a4 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts @@ -79,4 +79,4 @@ export const zPostFooData = z.object({ query: z.optional(z.never()) }); -export type PostFooDataZodType = z.infer; \ No newline at end of file +export type PostFooDataZodType = z.infer; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts index 11e304b1b..bd49adf30 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts @@ -41,4 +41,4 @@ export const zPetStore = z.object({ zCatDetails ]) })) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators/zod.gen.ts index 0fa87bffe..5bcc24c6f 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators/zod.gen.ts @@ -63,4 +63,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts index 91997b20b..e9ac7e7aa 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.array(zBar).min(1).max(2147483647).optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/default/zod.gen.ts index 284af38ad..968144790 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/default/zod.gen.ts @@ -1785,4 +1785,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts index 2b8373603..941cd87ea 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts index 6a995d9b3..e577fd348 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts @@ -34,4 +34,4 @@ export const zFoo = z.object({ integerUint64: z.number().int().optional(), stringInt64: z.literal('-9223372036854775808').optional(), stringUint64: z.literal('18446744073709551615').optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts index 5b3c0c45c..bcca2e71b 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts index cbd60cb15..b9a89eb4e 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts @@ -4,4 +4,4 @@ import { z } from 'zod'; export const zFoo = z.object({ foo: z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100)).optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts index fe5c68cc8..5c225d5ee 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts @@ -13,4 +13,4 @@ export const zBar: z.AnyZodObject = z.object({ export const zFoo: z.AnyZodObject = z.object({ foo: zBar -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts index 9ed4452c1..6050e6c5e 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts @@ -19,4 +19,4 @@ export const zQux: z.ZodTypeAny = z.lazy(() => { return zQux; }); -export const zBaz: z.ZodTypeAny = zQux; \ No newline at end of file +export const zBaz: z.ZodTypeAny = zQux; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts index 7d3bc1d19..6eb670417 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts @@ -63,4 +63,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts index b269940da..585fddbb2 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts @@ -61,4 +61,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts index 1a96490b6..ace814995 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts @@ -77,4 +77,4 @@ export const zPostFooData = z.object({ query: z.never().optional() }); -export type PostFooDataZodType = z.infer; \ No newline at end of file +export type PostFooDataZodType = z.infer; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts index 2a9dd621f..83c308d68 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts @@ -41,4 +41,4 @@ export const zPetStore = z.object({ zCatDetails ]) })) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators/zod.gen.ts index f8adb5f3f..83f84b2d0 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators/zod.gen.ts @@ -61,4 +61,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts index ea9d76fb3..5f2eda424 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).min(1).max(2147483647)) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts index c6380f76b..ffd9033d7 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts @@ -1787,4 +1787,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts index ac6994702..8ebbc33b6 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts index 7076092af..961bdec15 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts @@ -34,4 +34,4 @@ export const zFoo = z.object({ integerUint64: z.optional(z.int()), stringInt64: z.optional(z.literal('-9223372036854775808')), stringUint64: z.optional(z.literal('18446744073709551615')) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts index b79373215..c0a77c99d 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts index 087712a4d..8f2b8f572 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts @@ -4,4 +4,4 @@ import { z } from 'zod/v4'; export const zFoo = z.object({ foo: z.optional(z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts index d67b3c1cd..8f4290291 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts @@ -13,4 +13,4 @@ export const zBar = z.object({ export const zFoo = z.object({ foo: zBar -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts index 0d3e704cb..cc305b0c7 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts @@ -21,4 +21,4 @@ export const zQux = z.lazy((): any => { return zQux; }); -export const zBaz = zQux; \ No newline at end of file +export const zBaz = zQux; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts index b65fa7128..fa1234e0a 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts @@ -65,4 +65,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts index 1d6c9f57e..5e997ec27 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts @@ -75,4 +75,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts index 2b9fd480e..2794c6a1e 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts @@ -79,4 +79,4 @@ export const zPostFooData = z.object({ query: z.optional(z.never()) }); -export type PostFooDataZodType = z.infer; \ No newline at end of file +export type PostFooDataZodType = z.infer; diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts index 41f1b60c9..197f5de1d 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts @@ -41,4 +41,4 @@ export const zPetStore = z.object({ zCatDetails ]) })) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators/zod.gen.ts index e93af974b..f9c56845a 100644 --- a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators/zod.gen.ts @@ -63,4 +63,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts index b1217abc0..ee9d8176a 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts @@ -780,4 +780,4 @@ export const zPostApiVbyApiVersionBodyData = z.object({ /** * OK */ -export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; \ No newline at end of file +export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts index 1a7f5a539..c1893f1c6 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts index ce259bece..69da954a5 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts @@ -778,4 +778,4 @@ export const zPostApiVbyApiVersionBodyData = z.object({ /** * OK */ -export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; \ No newline at end of file +export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts index ebeac913d..38cd69d09 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts index 31b6dd3b8..fdfcad8c4 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts @@ -780,4 +780,4 @@ export const zPostApiVbyApiVersionBodyData = z.object({ /** * OK */ -export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; \ No newline at end of file +export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts index bfee2ff85..477553d5c 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts index c28387394..f7edab532 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts index 315648e1b..821e28743 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts @@ -1771,4 +1771,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts index 084c93ee0..fb5d80a30 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts index 1a7f5a539..c1893f1c6 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/validators/zod.gen.ts index 343657678..77ab57f60 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/validators/zod.gen.ts @@ -22,4 +22,4 @@ export const zFoo = z._default(z.union([ z.null() ]), null); -export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); \ No newline at end of file +export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts index d6e23fb2f..efb23578b 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.array(zBar).min(1).max(2147483647).optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts index 83b4147f1..4e19fcbfb 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts @@ -1769,4 +1769,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts index b3477bf27..c9196982b 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts index ebeac913d..38cd69d09 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/validators/zod.gen.ts index 01928bc8f..1b13ab9cb 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/validators/zod.gen.ts @@ -20,4 +20,4 @@ export const zFoo: z.ZodTypeAny = z.union([ z.null() ]).default(null); -export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); \ No newline at end of file +export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts index 1b393bda1..df10c1422 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).min(1).max(2147483647)) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts index be696c929..dfb05e511 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts @@ -1771,4 +1771,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts index d79efe5d2..83397c84f 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts index bfee2ff85..477553d5c 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/validators/zod.gen.ts index e9044ceb6..7f3ce000b 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/validators/zod.gen.ts @@ -22,4 +22,4 @@ export const zFoo = z.union([ z.null() ]).default(null); -export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); \ No newline at end of file +export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts index c28387394..f7edab532 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts index 03bb3d55e..db575e570 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts @@ -1787,4 +1787,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts index 084c93ee0..fb5d80a30 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts index d58149c6e..1b4e0e1cf 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts @@ -34,4 +34,4 @@ export const zFoo = z.object({ integerUint64: z.optional(z.int()), stringInt64: z.optional(z.literal('-9223372036854775808')), stringUint64: z.optional(z.literal('18446744073709551615')) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts index 1a7f5a539..c1893f1c6 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts index 4d4d93b43..4c7407f99 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts @@ -4,4 +4,4 @@ import * as z from 'zod/mini'; export const zFoo = z.object({ foo: z.optional(z.coerce.bigint().check(z.gte(BigInt(0)), z.lte(BigInt(100)))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts index fa78939fd..aed07582c 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts @@ -13,4 +13,4 @@ export const zBar = z.object({ export const zFoo = z.object({ foo: zBar -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts index b5a3b1153..2e65ce311 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts @@ -21,4 +21,4 @@ export const zQux = z.lazy((): any => { return zQux; }); -export const zBaz = zQux; \ No newline at end of file +export const zBaz = zQux; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts index f5e6d804c..f5db2ce5c 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts @@ -65,4 +65,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts index 0089cf010..4b4759e2d 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts @@ -75,4 +75,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts index 1d1545e1f..1eb0cfb95 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts @@ -79,4 +79,4 @@ export const zPostFooData = z.object({ query: z.optional(z.never()) }); -export type PostFooDataZodType = z.infer; \ No newline at end of file +export type PostFooDataZodType = z.infer; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts index 86003751f..8a820c15d 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts @@ -41,4 +41,4 @@ export const zPetStore = z.object({ zCatDetails ]) })) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators/zod.gen.ts index 04f65c781..0ee090a1a 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators/zod.gen.ts @@ -63,4 +63,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts index d6e23fb2f..efb23578b 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.array(zBar).min(1).max(2147483647).optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts index 1015dc00d..c4a1f074c 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts @@ -1785,4 +1785,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts index b3477bf27..c9196982b 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts index c3a2e362f..2f582cbad 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts @@ -34,4 +34,4 @@ export const zFoo = z.object({ integerUint64: z.number().int().optional(), stringInt64: z.literal('-9223372036854775808').optional(), stringUint64: z.literal('18446744073709551615').optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts index ebeac913d..38cd69d09 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts index 702b021c9..d2ab7d427 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts @@ -4,4 +4,4 @@ import { z } from 'zod/v3'; export const zFoo = z.object({ foo: z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100)).optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts index da59ef9db..0b40b33a2 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts @@ -13,4 +13,4 @@ export const zBar: z.AnyZodObject = z.object({ export const zFoo: z.AnyZodObject = z.object({ foo: zBar -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts index c64ceaa73..81f594b60 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts @@ -19,4 +19,4 @@ export const zQux: z.ZodTypeAny = z.lazy(() => { return zQux; }); -export const zBaz: z.ZodTypeAny = zQux; \ No newline at end of file +export const zBaz: z.ZodTypeAny = zQux; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts index 575a66456..140dc5e8c 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts @@ -63,4 +63,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts index dd909ef91..efc9209a2 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts @@ -61,4 +61,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts index 29f89864b..399d2c413 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts @@ -77,4 +77,4 @@ export const zPostFooData = z.object({ query: z.never().optional() }); -export type PostFooDataZodType = z.infer; \ No newline at end of file +export type PostFooDataZodType = z.infer; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts index 23c1d7fb2..754b9133a 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts @@ -41,4 +41,4 @@ export const zPetStore = z.object({ zCatDetails ]) })) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators/zod.gen.ts index 47451c58f..fcc9c8c55 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators/zod.gen.ts @@ -61,4 +61,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.never().optional(), query: z.never().optional() -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts index 1b393bda1..df10c1422 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts @@ -6,4 +6,4 @@ export const zBar = z.string(); export const zFoo = z.object({ foo: z.optional(z.array(zBar).min(1).max(2147483647)) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts index f84bc5d09..a08796446 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts @@ -1787,4 +1787,4 @@ export const zPutWithFormUrlEncodedData = z.object({ body: zArrayWithStrings, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts index d79efe5d2..83397c84f 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts @@ -15,4 +15,4 @@ export const zBar = z.enum([ export const zBaz = z.enum([ 'foo', 'bar' -]); \ No newline at end of file +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts index f47c38147..2b7e1c462 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts @@ -34,4 +34,4 @@ export const zFoo = z.object({ integerUint64: z.optional(z.int()), stringInt64: z.optional(z.literal('-9223372036854775808')), stringUint64: z.optional(z.literal('18446744073709551615')) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts index bfee2ff85..477553d5c 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts @@ -21,4 +21,4 @@ export const zPostFooData = z.object({ /** * OK */ -export const zPostFooResponse = zFoo; \ No newline at end of file +export const zPostFooResponse = zFoo; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts index eb3ccb962..f04eccbf2 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts @@ -4,4 +4,4 @@ import { z } from 'zod'; export const zFoo = z.object({ foo: z.optional(z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100))) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts index 8b058709a..f63841106 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts @@ -13,4 +13,4 @@ export const zBar = z.object({ export const zFoo = z.object({ foo: zBar -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts index 8fbd29229..1fa3416dd 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts @@ -21,4 +21,4 @@ export const zQux = z.lazy((): any => { return zQux; }); -export const zBaz = zQux; \ No newline at end of file +export const zBaz = zQux; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts index 7a3e6c6b7..9b0132631 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts @@ -65,4 +65,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts index fc9c4caaa..34e6fe096 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts @@ -75,4 +75,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts index 011094631..649cd0534 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts @@ -79,4 +79,4 @@ export const zPostFooData = z.object({ query: z.optional(z.never()) }); -export type PostFooDataZodType = z.infer; \ No newline at end of file +export type PostFooDataZodType = z.infer; diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts index dbebab297..3971835be 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts @@ -41,4 +41,4 @@ export const zPetStore = z.object({ zCatDetails ]) })) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators/zod.gen.ts index dd2dc5c96..921e41c46 100644 --- a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators/zod.gen.ts +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators/zod.gen.ts @@ -63,4 +63,4 @@ export const zPostFooData = z.object({ body: zFoo3, path: z.optional(z.never()), query: z.optional(z.never()) -}); \ No newline at end of file +}); diff --git a/packages/openapi-ts/src/plugins/zod/mini/plugin.ts b/packages/openapi-ts/src/plugins/zod/mini/plugin.ts index 0eac8ea88..1a1f6bfd3 100644 --- a/packages/openapi-ts/src/plugins/zod/mini/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/mini/plugin.ts @@ -1223,11 +1223,8 @@ export const handlerMini: ZodPlugin['Handler'] = ({ plugin }) => { selector: plugin.api.getSelector('import', 'zod'), }); f.addImport({ - aliases: { - z: zSymbol.placeholder, - }, from: getZodModule({ plugin }), - names: ['z'], + namespaceImport: zSymbol.placeholder, }); plugin.forEach( diff --git a/packages/openapi-ts/src/plugins/zod/v3/plugin.ts b/packages/openapi-ts/src/plugins/zod/v3/plugin.ts index 3766c48b8..a54a7e903 100644 --- a/packages/openapi-ts/src/plugins/zod/v3/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/v3/plugin.ts @@ -1109,10 +1109,10 @@ export const handlerV3: ZodPlugin['Handler'] = ({ plugin }) => { }); f.addImport({ aliases: { - z: zSymbol.placeholder, + [zSymbol.name]: zSymbol.placeholder, }, from: getZodModule({ plugin }), - names: ['z'], + names: [zSymbol.name], }); plugin.forEach( diff --git a/packages/openapi-ts/src/plugins/zod/v4/plugin.ts b/packages/openapi-ts/src/plugins/zod/v4/plugin.ts index 67c1c4bc0..e4f28b3e3 100644 --- a/packages/openapi-ts/src/plugins/zod/v4/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/v4/plugin.ts @@ -1182,10 +1182,10 @@ export const handlerV4: ZodPlugin['Handler'] = ({ plugin }) => { }); f.addImport({ aliases: { - z: zSymbol.placeholder, + [zSymbol.name]: zSymbol.placeholder, }, from: getZodModule({ plugin }), - names: ['z'], + names: [zSymbol.name], }); plugin.forEach(