diff --git a/.changeset/brown-paws-design.md b/.changeset/brown-paws-design.md index a3a5f9f0e..81b00784f 100644 --- a/.changeset/brown-paws-design.md +++ b/.changeset/brown-paws-design.md @@ -2,4 +2,10 @@ '@hey-api/openapi-ts': minor --- -feat: add symbol api +feat: Symbol API + +### Symbol API + +This release adds the Symbol API, which significantly reduces the risk of naming collisions. While the generated output should only include formatting changes, this feature introduces breaking changes to the Plugin API that affect custom plugins. + +We will update the [custom plugin guide](https://heyapi.dev/openapi-ts/plugins/custom) once the Plugin API becomes more stable. diff --git a/.changeset/cuddly-bears-deny.md b/.changeset/cuddly-bears-deny.md index 3082d56aa..6d5449edc 100644 --- a/.changeset/cuddly-bears-deny.md +++ b/.changeset/cuddly-bears-deny.md @@ -2,4 +2,4 @@ '@hey-api/codegen-core': minor --- -feat: expand symbol api +feat: expand Symbol API diff --git a/.changeset/thirty-shoes-end.md b/.changeset/thirty-shoes-end.md index 8acacc334..ab22290d2 100644 --- a/.changeset/thirty-shoes-end.md +++ b/.changeset/thirty-shoes-end.md @@ -2,4 +2,8 @@ '@hey-api/openapi-ts': minor --- -feat(pinia-colada): remove groupByTag option +feat(pinia-colada): remove `groupByTag` option + +### Removed `groupByTag` Pinia Colada option + +This option has been removed to provide a more consistent API across plugins. We plan to bring it back in a future release. diff --git a/docs/.vitepress/config/en.ts b/docs/.vitepress/config/en.ts index d9e5b4c4b..56be1a690 100644 --- a/docs/.vitepress/config/en.ts +++ b/docs/.vitepress/config/en.ts @@ -48,6 +48,10 @@ export default defineConfig({ link: '/openapi-ts/configuration', text: 'Configuration', }, + { + link: '/openapi-ts/output', + text: 'Output', + }, ], text: 'Introduction', }, @@ -57,35 +61,24 @@ export default defineConfig({ collapsed: true, items: [ { - link: '/openapi-ts/output/typescript', + link: '/openapi-ts/plugins/typescript', text: 'TypeScript', }, { - link: '/openapi-ts/output/sdk', + link: '/openapi-ts/plugins/sdk', text: 'SDK', }, { - link: '/openapi-ts/output/client', - text: 'Client', - }, - { - link: '/openapi-ts/output/json-schema', - text: 'JSON Schema', + link: '/openapi-ts/plugins/transformers', + text: 'Transformers', }, - ], - link: '/openapi-ts/output', - text: 'Output', - }, - { - collapsed: true, - items: [ { - link: '/openapi-ts/plugins/custom', - text: 'Custom Plugin', + link: '/openapi-ts/plugins/schemas', + text: 'Schemas', }, ], - link: '/openapi-ts/plugins', - text: 'Plugins', + link: '/openapi-ts/core', + text: 'Core', }, { collapsed: true, @@ -114,10 +107,6 @@ export default defineConfig({ link: '/openapi-ts/clients/effect', text: 'Effect soon', }, - { - link: '/openapi-ts/clients/custom', - text: 'Custom Client', - }, { link: '/openapi-ts/clients/legacy', text: 'Legacy', @@ -165,10 +154,6 @@ export default defineConfig({ link: '/openapi-ts/validators', text: 'Validators', }, - { - link: '/openapi-ts/transformers', - text: 'Transformers', - }, { collapsed: true, items: [ @@ -258,6 +243,20 @@ export default defineConfig({ link: '/openapi-ts/web-frameworks', text: 'Web Frameworks', }, + { + collapsed: true, + items: [ + { + link: '/openapi-ts/plugins/custom', + text: 'Plugin', + }, + { + link: '/openapi-ts/clients/custom', + text: 'Client', + }, + ], + text: 'Custom', + }, ], text: 'Guides and Concepts', }, diff --git a/docs/index.md b/docs/index.md index 14e98eff6..d1a9d5df9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,7 +3,7 @@ layout: home hero: name: One OpenAPI spec.
Infinite outputs. - tagline: Codegen for JavaScript/TypeScript projects. Trusted over 2,000,000 times each month to generate reliable API clients and SDKs. + tagline: Codegen for JavaScript/TypeScript projects. Trusted over 2,500,000 times each month to generate reliable API clients and SDKs. actions: - link: /openapi-ts/get-started text: Get Started diff --git a/docs/openapi-ts/core.md b/docs/openapi-ts/core.md new file mode 100644 index 000000000..6bfc69e41 --- /dev/null +++ b/docs/openapi-ts/core.md @@ -0,0 +1,22 @@ +--- +title: Core Plugins +description: Learn about the core plugins provided by Hey API. +--- + +# Core + +Apart from being responsible for the default output, core plugins are the foundation for other plugins. Instead of creating their own primitives, other plugins can reuse the artifacts from core plugins. This results in a smaller output size and a better user experience. + +## Options + +Hey API provides the following core plugins. + +- [TypeScript](/openapi-ts/plugins/typescript) +- [SDK](/openapi-ts/plugins/sdk) +- [Transformers](/openapi-ts/plugins/transformers) +- [Schemas](/openapi-ts/plugins/schemas) + +Need another core plugin? Let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues). + + + diff --git a/docs/openapi-ts/get-started.md b/docs/openapi-ts/get-started.md index 088de98bb..8c151a52b 100644 --- a/docs/openapi-ts/get-started.md +++ b/docs/openapi-ts/get-started.md @@ -9,7 +9,7 @@ import { embedProject } from '../embed' # Get Started -[@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) is an OpenAPI to TypeScript codegen trusted over 2,000,000 times each month to generate reliable API clients and SDKs. The code is [MIT-licensed](/openapi-ts/license) and free to use. Discover available features below or view our [roadmap](https://github.com/orgs/hey-api/discussions/1495) to learn what's coming next. +[@hey-api/openapi-ts](https://github.com/hey-api/openapi-ts) is an OpenAPI to TypeScript codegen trusted over 2,500,000 times each month to generate reliable API clients and SDKs. The code is [MIT-licensed](/openapi-ts/license) and free to use. Discover available features below or view our [roadmap](https://github.com/orgs/hey-api/discussions/1495) to learn what's coming next. ### Demo diff --git a/docs/openapi-ts/migrating.md b/docs/openapi-ts/migrating.md index 986cd23f3..92075b289 100644 --- a/docs/openapi-ts/migrating.md +++ b/docs/openapi-ts/migrating.md @@ -7,9 +7,21 @@ description: Migrating to @hey-api/openapi-ts. While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features. This page lists changes that require updates to your code. If you run into a problem with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues). +## v0.83.0 + +### Symbol API + +This release adds the Symbol API, which significantly reduces the risk of naming collisions. While the generated output should only include formatting changes, this feature introduces breaking changes to the Plugin API that affect custom plugins. + +We will update the [custom plugin guide](/openapi-ts/plugins/custom) once the Plugin API becomes more stable. + +### Removed `groupByTag` Pinia Colada option + +This option has been removed to provide a more consistent API across plugins. We plan to bring it back in a future release. + ## v0.82.0 -### Added Hooks API +### Hooks API This release adds the [Hooks API](/openapi-ts/configuration/parser#hooks), giving you granular control over which operations generate queries and mutations. As a result, we tightened the previous behavior and POST operations no longer generate queries by default. To preserve the old behavior, add a custom matcher. diff --git a/docs/openapi-ts/output.md b/docs/openapi-ts/output.md index 6acd16d8c..174b46601 100644 --- a/docs/openapi-ts/output.md +++ b/docs/openapi-ts/output.md @@ -5,11 +5,7 @@ description: Learn about files generated with @hey-api/openapi-ts. # Output -Learn about files generated with `@hey-api/openapi-ts`. - -::: tip -Your actual output depends on your Hey API configuration. It may contain a different number of files and their contents might differ. -::: +Every generated file in your output folder is created by a plugin. This page describes the default output, but similar logic applies to all plugins. ## Overview @@ -30,13 +26,41 @@ my-app/ └── package.json ``` -Each file is an artifact generated by a Hey API plugin. This is the default output, we will cover customizing it in this section. These files also form the base for third-party plugins. +Your actual output depends on your Hey API configuration. It may contain a different number of files and their contents might differ. Let's go through each file in the `src/client` folder and explain what it looks like, what it does, and how to use it. -## Index +## Client + +`client.gen.ts` is generated by [client plugins](/openapi-ts/clients). If you choose to generate SDKs (enabled by default), we use the Fetch client unless specified otherwise. + +::: code-group + +```ts [client.gen.ts] +import { createClient, createConfig } from './client'; + +export const client = createClient(createConfig()); +``` + +::: + +The contents of this file are consumed by SDKs, but you can also import `client` in your application to perform additional configuration or send manual requests. + +### Bundle + +Client plugins provide their bundles inside `client` and `core` folders. The contents of these folders don't depend on the provided input. Everything inside these folders serves as a scaffolding so the generated code can make HTTP requests. + +## TypeScript + +You can learn more on the [TypeScript](/openapi-ts/plugins/typescript) page. + +## SDK + +You can learn more on the [SDK](/openapi-ts/plugins/sdk) page. + +## Barrel File -`index.ts` is the only file not generated by a specific plugin. It's meant for convenience and by default, it re-exports every artifact generated by default plugins (TypeScript and SDK). +`index.ts` is not generated by any specific plugin. It's meant for convenience and by default, it re-exports every artifact generated by default plugins (TypeScript and SDK). ::: code-group diff --git a/docs/openapi-ts/output/client.md b/docs/openapi-ts/output/client.md deleted file mode 100644 index f66009f02..000000000 --- a/docs/openapi-ts/output/client.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -title: Client -description: Learn about files generated with @hey-api/openapi-ts. ---- - -# Client - -`client.gen.ts` is generated by [client plugins](/openapi-ts/clients). If you choose to generate SDKs (enabled by default), we use the Fetch client unless specified otherwise. - -::: code-group - -```ts [client.gen.ts] -import { createClient, createConfig } from './client'; - -export const client = createClient(createConfig()); -``` - -::: - -The contents of this file are consumed by SDKs, but you can also import `client` in your application to perform additional configuration or send manual requests. - -## Bundle - -Client plugins provide their bundles inside `client` and `core` folders. The contents of these folders don't depend on the provided input. Everything inside these folders serves as a scaffolding so the generated code can make HTTP requests. - - - diff --git a/docs/openapi-ts/plugins.md b/docs/openapi-ts/plugins.md deleted file mode 100644 index 321b66c47..000000000 --- a/docs/openapi-ts/plugins.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: Plugins -description: Learn about and discover available plugins. ---- - -# Plugins - -Every generated file in your output is created by a plugin. You already learned about the default plugins in [Output](/openapi-ts/output). However, you might be working with third-party packages and wishing to automate more of your boilerplate. This page lists all native and selected community plugins enabling you to do that. - -## Core - -Apart from being responsible for the default output, core plugins are the foundation for other plugins. Instead of creating their own primitives, other plugins can reuse the artifacts from core plugins. This results in a smaller output size and a better user experience. - -- [`@hey-api/schemas`](/openapi-ts/output/json-schema) - export OpenAPI definitions as JavaScript objects -- [`@hey-api/sdk`](/openapi-ts/output/sdk) - robust and polished SDKs -- [`@hey-api/transformers`](/openapi-ts/transformers) - response data transformer functions -- [`@hey-api/typescript`](/openapi-ts/output/typescript) - TypeScript interfaces and enums - -## Third Party - -These plugins help reduce boilerplate associated with third-party dependencies. Hey API natively supports the most popular packages. Please open an issue on [GitHub](https://github.com/hey-api/openapi-ts/issues) if you'd like us to support your favorite package. - -- [`@angular/common`](/openapi-ts/plugins/angular) -- [`@pinia/colada`](/openapi-ts/plugins/pinia-colada) -- [`@tanstack/angular-query-experimental`](/openapi-ts/plugins/tanstack-query) -- [`@tanstack/react-query`](/openapi-ts/plugins/tanstack-query) -- [`@tanstack/solid-query`](/openapi-ts/plugins/tanstack-query) -- [`@tanstack/svelte-query`](/openapi-ts/plugins/tanstack-query) -- [`@tanstack/vue-query`](/openapi-ts/plugins/tanstack-query) -- [`fastify`](/openapi-ts/plugins/fastify) -- [`valibot`](/openapi-ts/plugins/valibot) -- [`zod`](/openapi-ts/plugins/zod) - -## Upcoming - -The following plugins are planned but not in development yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/openapi-ts/labels/RSVP%20%F0%9F%91%8D%F0%9F%91%8E). - -- [Adonis](/openapi-ts/plugins/adonis) Soon -- [Ajv](/openapi-ts/plugins/ajv) Soon -- [Arktype](/openapi-ts/plugins/arktype) Soon -- [Chance](/openapi-ts/plugins/chance) Soon -- [Express](/openapi-ts/plugins/express) Soon -- [Faker](/openapi-ts/plugins/faker) Soon -- [Falso](/openapi-ts/plugins/falso) Soon -- [Hono](/openapi-ts/plugins/hono) Soon -- [Joi](/openapi-ts/plugins/joi) Soon -- [Koa](/openapi-ts/plugins/koa) Soon -- [MSW](/openapi-ts/plugins/msw) Soon -- [Nest](/openapi-ts/plugins/nest) Soon -- [Nock](/openapi-ts/plugins/nock) Soon -- [Superstruct](/openapi-ts/plugins/superstruct) Soon -- [Supertest](/openapi-ts/plugins/supertest) Soon -- [SWR](/openapi-ts/plugins/swr) Soon -- [TypeBox](/openapi-ts/plugins/typebox) Soon -- [Yup](/openapi-ts/plugins/yup) Soon -- [Zustand](/openapi-ts/plugins/zustand) Soon - -Don't see your plugin? [Build your own](/openapi-ts/plugins/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues). - - - diff --git a/docs/openapi-ts/plugins/custom.md b/docs/openapi-ts/plugins/custom.md index 8cd3dc70b..109eaad3f 100644 --- a/docs/openapi-ts/plugins/custom.md +++ b/docs/openapi-ts/plugins/custom.md @@ -9,6 +9,10 @@ description: Learn how to create your own Hey API plugin. Plugin API is in development. The interface might change before it becomes stable. We encourage you to leave feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues). ::: +::: warning +This page is out of date as of [v0.83.0](/openapi-ts/migrating#v0-83-0). If you have an existing custom plugin, we recommend waiting for a more stable Plugin API to avoid multiple plugin rewrites. +::: + You may need to write your own plugin if the available plugins do not suit your needs or you're working on a proprietary use case. This can be easily achieved using the Plugin API. But don't take our word for it – all Hey API plugins are written this way! ## File Structure diff --git a/docs/openapi-ts/output/json-schema.md b/docs/openapi-ts/plugins/schemas.md similarity index 100% rename from docs/openapi-ts/output/json-schema.md rename to docs/openapi-ts/plugins/schemas.md diff --git a/docs/openapi-ts/output/sdk.md b/docs/openapi-ts/plugins/sdk.md similarity index 100% rename from docs/openapi-ts/output/sdk.md rename to docs/openapi-ts/plugins/sdk.md diff --git a/docs/openapi-ts/transformers.md b/docs/openapi-ts/plugins/transformers.md similarity index 100% rename from docs/openapi-ts/transformers.md rename to docs/openapi-ts/plugins/transformers.md diff --git a/docs/openapi-ts/output/typescript.md b/docs/openapi-ts/plugins/typescript.md similarity index 100% rename from docs/openapi-ts/output/typescript.md rename to docs/openapi-ts/plugins/typescript.md diff --git a/docs/openapi-ts/plugins/valibot.md b/docs/openapi-ts/plugins/valibot.md index 9c95d4829..77f6e6f8e 100644 --- a/docs/openapi-ts/plugins/valibot.md +++ b/docs/openapi-ts/plugins/valibot.md @@ -60,7 +60,7 @@ export default { }; ``` -Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/output/sdk#validators) page. +Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/plugins/sdk#validators) page. ## Output diff --git a/docs/openapi-ts/plugins/zod.md b/docs/openapi-ts/plugins/zod.md index b5f2dec07..ff0b9dc45 100644 --- a/docs/openapi-ts/plugins/zod.md +++ b/docs/openapi-ts/plugins/zod.md @@ -60,7 +60,7 @@ export default { }; ``` -Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/output/sdk#validators) page. +Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/plugins/sdk#validators) page. ## Output diff --git a/docs/openapi-ts/plugins/zod/mini.md b/docs/openapi-ts/plugins/zod/mini.md index dfe96ae0e..e51b143b3 100644 --- a/docs/openapi-ts/plugins/zod/mini.md +++ b/docs/openapi-ts/plugins/zod/mini.md @@ -66,7 +66,7 @@ export default { }; ``` -Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/output/sdk#validators) page. +Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/plugins/sdk#validators) page. ## Output diff --git a/docs/openapi-ts/plugins/zod/v3.md b/docs/openapi-ts/plugins/zod/v3.md index ac308174d..65d10b564 100644 --- a/docs/openapi-ts/plugins/zod/v3.md +++ b/docs/openapi-ts/plugins/zod/v3.md @@ -66,7 +66,7 @@ export default { }; ``` -Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/output/sdk#validators) page. +Learn more about data validators in your SDKs on the [SDKs](/openapi-ts/plugins/sdk#validators) page. ## Output diff --git a/docs/vercel.json b/docs/vercel.json index aa4626317..2ddb9169c 100644 --- a/docs/vercel.json +++ b/docs/vercel.json @@ -15,6 +15,31 @@ "source": "/openapi-ts/custom-plugin", "destination": "/openapi-ts/plugins/custom", "permanent": true + }, + { + "source": "/openapi-ts/plugins", + "destination": "/openapi-ts/core", + "permanent": true + }, + { + "source": "/openapi-ts/output/json-schema", + "destination": "/openapi-ts/plugins/schemas", + "permanent": true + }, + { + "source": "/openapi-ts/output/sdk", + "destination": "/openapi-ts/plugins/sdk", + "permanent": true + }, + { + "source": "/openapi-ts/transformers", + "destination": "/openapi-ts/plugins/transformers", + "permanent": true + }, + { + "source": "/openapi-ts/output/typescript", + "destination": "/openapi-ts/plugins/typescript", + "permanent": true } ], "trailingSlash": false -- 2.51.2 From 264b54bed18f40854f0b49ed6caeb20d922d33f8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 11:39:53 +0000 Subject: [PATCH 02/19] ci: release --- .changeset/brown-paws-design.md | 11 ----------- .changeset/cuddly-bears-deny.md | 5 ----- .changeset/thirty-shoes-end.md | 9 --------- packages/codegen-core/CHANGELOG.md | 6 ++++++ packages/codegen-core/package.json | 2 +- packages/openapi-ts/CHANGELOG.md | 24 ++++++++++++++++++++++++ packages/openapi-ts/package.json | 4 ++-- 7 files changed, 33 insertions(+), 28 deletions(-) delete mode 100644 .changeset/brown-paws-design.md delete mode 100644 .changeset/cuddly-bears-deny.md delete mode 100644 .changeset/thirty-shoes-end.md diff --git a/.changeset/brown-paws-design.md b/.changeset/brown-paws-design.md deleted file mode 100644 index 81b00784f..000000000 --- a/.changeset/brown-paws-design.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -'@hey-api/openapi-ts': minor ---- - -feat: Symbol API - -### Symbol API - -This release adds the Symbol API, which significantly reduces the risk of naming collisions. While the generated output should only include formatting changes, this feature introduces breaking changes to the Plugin API that affect custom plugins. - -We will update the [custom plugin guide](https://heyapi.dev/openapi-ts/plugins/custom) once the Plugin API becomes more stable. diff --git a/.changeset/cuddly-bears-deny.md b/.changeset/cuddly-bears-deny.md deleted file mode 100644 index 6d5449edc..000000000 --- a/.changeset/cuddly-bears-deny.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@hey-api/codegen-core': minor ---- - -feat: expand Symbol API diff --git a/.changeset/thirty-shoes-end.md b/.changeset/thirty-shoes-end.md deleted file mode 100644 index ab22290d2..000000000 --- a/.changeset/thirty-shoes-end.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -'@hey-api/openapi-ts': minor ---- - -feat(pinia-colada): remove `groupByTag` option - -### Removed `groupByTag` Pinia Colada option - -This option has been removed to provide a more consistent API across plugins. We plan to bring it back in a future release. diff --git a/packages/codegen-core/CHANGELOG.md b/packages/codegen-core/CHANGELOG.md index e33a0681d..eeb500c37 100644 --- a/packages/codegen-core/CHANGELOG.md +++ b/packages/codegen-core/CHANGELOG.md @@ -1,5 +1,11 @@ # @hey-api/codegen-core +## 0.1.0 + +### Minor Changes + +- feat: expand Symbol API ([#2582](https://github.com/hey-api/openapi-ts/pull/2582)) ([`10aea89`](https://github.com/hey-api/openapi-ts/commit/10aea8910771ff72ef9b08d4eacdd6b028833c4c)) by [@mrlubos](https://github.com/mrlubos) + ## 0.0.1 ### Patch Changes diff --git a/packages/codegen-core/package.json b/packages/codegen-core/package.json index fb88150bd..de2c656e7 100644 --- a/packages/codegen-core/package.json +++ b/packages/codegen-core/package.json @@ -1,6 +1,6 @@ { "name": "@hey-api/codegen-core", - "version": "0.0.1", + "version": "0.1.0", "description": "🧱 TypeScript framework for generating structured, multi-file source code from abstract syntax trees.", "homepage": "https://heyapi.dev/", "repository": { diff --git a/packages/openapi-ts/CHANGELOG.md b/packages/openapi-ts/CHANGELOG.md index e4fd2042f..149789736 100644 --- a/packages/openapi-ts/CHANGELOG.md +++ b/packages/openapi-ts/CHANGELOG.md @@ -1,5 +1,29 @@ # @hey-api/openapi-ts +## 0.83.0 + +### Minor Changes + +- feat: Symbol API + +### Symbol API + +This release adds the Symbol API, which significantly reduces the risk of naming collisions. While the generated output should only include formatting changes, this feature introduces breaking changes to the Plugin API that affect custom plugins. + +We will update the [custom plugin guide](https://heyapi.dev/openapi-ts/plugins/custom) once the Plugin API becomes more stable. ([#2582](https://github.com/hey-api/openapi-ts/pull/2582)) ([`10aea89`](https://github.com/hey-api/openapi-ts/commit/10aea8910771ff72ef9b08d4eacdd6b028833c4c)) by [@mrlubos](https://github.com/mrlubos) + +- feat(pinia-colada): remove `groupByTag` option + +### Removed `groupByTag` Pinia Colada option + +This option has been removed to provide a more consistent API across plugins. We plan to bring it back in a future release. ([#2582](https://github.com/hey-api/openapi-ts/pull/2582)) ([`10aea89`](https://github.com/hey-api/openapi-ts/commit/10aea8910771ff72ef9b08d4eacdd6b028833c4c)) by [@mrlubos](https://github.com/mrlubos) + +### Patch Changes + +### Updated Dependencies: + +- @hey-api/codegen-core@0.1.0 + ## 0.82.5 ### Patch Changes diff --git a/packages/openapi-ts/package.json b/packages/openapi-ts/package.json index 81a8e54d6..0efd71b5f 100644 --- a/packages/openapi-ts/package.json +++ b/packages/openapi-ts/package.json @@ -1,6 +1,6 @@ { "name": "@hey-api/openapi-ts", - "version": "0.82.5", + "version": "0.83.0", "description": "🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.", "homepage": "https://heyapi.dev/", "repository": { @@ -88,7 +88,7 @@ "node": "^18.18.0 || ^20.9.0 || >=22.10.0" }, "dependencies": { - "@hey-api/codegen-core": "workspace:^0.0.1", + "@hey-api/codegen-core": "workspace:^0.1.0", "@hey-api/json-schema-ref-parser": "1.1.0", "ansi-colors": "4.1.3", "c12": "2.0.1", -- 2.51.2 From 7124cd764b69b04f9bd22fcf5f42b02cdeccae89 Mon Sep 17 00:00:00 2001 From: mrlubos <12529395+mrlubos@users.noreply.github.com> Date: Wed, 10 Sep 2025 11:41:04 +0000 Subject: [PATCH 03/19] chore: update lock file --- pnpm-lock.yaml | 241 ++----------------------------------------------- 1 file changed, 6 insertions(+), 235 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 64575ba99..4cd86ec6c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1174,7 +1174,7 @@ importers: packages/openapi-ts: dependencies: '@hey-api/codegen-core': - specifier: workspace:^0.0.1 + specifier: workspace:^0.1.0 version: link:../codegen-core '@hey-api/json-schema-ref-parser': specifier: 1.1.0 @@ -1257,7 +1257,7 @@ importers: version: 3.3.2 nuxt: specifier: 3.14.1592 - version: 3.14.1592(@netlify/blobs@9.1.2)(@parcel/watcher@2.5.1)(@types/node@22.10.5)(db0@0.3.2)(encoding@0.1.13)(eslint@9.17.0(jiti@2.5.1))(ioredis@5.7.0)(less@4.2.2)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.50.0)(sass@1.85.0)(terser@5.43.1)(typescript@5.8.3)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)) + version: 3.14.1592(@netlify/blobs@9.1.2)(@parcel/watcher@2.5.1)(@types/node@22.10.5)(db0@0.3.2)(encoding@0.1.13)(eslint@9.17.0(jiti@2.5.1))(ioredis@5.7.0)(less@4.2.2)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.50.0)(sass@1.85.0)(terser@5.43.1)(typescript@5.8.3)(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0)) prettier: specifier: 3.4.2 version: 3.4.2 @@ -17500,16 +17500,6 @@ snapshots: '@nuxt/devalue@2.0.2': {} - '@nuxt/devtools-kit@1.7.0(magicast@0.3.5)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1))': - dependencies: - '@nuxt/kit': 3.15.4(magicast@0.3.5) - '@nuxt/schema': 3.16.2 - execa: 7.2.0 - vite: 5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1) - transitivePeerDependencies: - - magicast - - supports-color - '@nuxt/devtools-kit@1.7.0(magicast@0.3.5)(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0))': dependencies: '@nuxt/kit': 3.15.4(magicast@0.3.5) @@ -17580,53 +17570,6 @@ snapshots: - utf-8-validate - vue - '@nuxt/devtools@1.7.0(rollup@4.50.0)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1))(vue@3.5.13(typescript@5.8.3))': - dependencies: - '@antfu/utils': 0.7.10 - '@nuxt/devtools-kit': 1.7.0(magicast@0.3.5)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)) - '@nuxt/devtools-wizard': 1.7.0 - '@nuxt/kit': 3.15.4(magicast@0.3.5) - '@vue/devtools-core': 7.6.8(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1))(vue@3.5.13(typescript@5.8.3)) - '@vue/devtools-kit': 7.6.8 - birpc: 0.2.19 - consola: 3.4.2 - cronstrue: 2.59.0 - destr: 2.0.5 - error-stack-parser-es: 0.1.5 - execa: 7.2.0 - fast-npm-meta: 0.2.2 - flatted: 3.3.3 - get-port-please: 3.2.0 - hookable: 5.5.3 - image-meta: 0.2.1 - is-installed-globally: 1.0.0 - launch-editor: 2.11.1 - local-pkg: 0.5.1 - magicast: 0.3.5 - nypm: 0.4.1 - ohash: 1.1.6 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - pkg-types: 1.3.1 - rc9: 2.1.2 - scule: 1.3.0 - semver: 7.7.2 - simple-git: 3.28.0 - sirv: 3.0.1 - tinyglobby: 0.2.10 - unimport: 3.14.6(rollup@4.50.0) - vite: 5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1) - vite-plugin-inspect: 0.8.9(@nuxt/kit@3.15.4(magicast@0.3.5))(rollup@4.50.0)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)) - vite-plugin-vue-inspector: 5.3.2(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)) - which: 3.0.1 - ws: 8.18.3 - transitivePeerDependencies: - - bufferutil - - rollup - - supports-color - - utf-8-validate - - vue - '@nuxt/devtools@1.7.0(rollup@4.50.0)(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0))(vue@3.5.13(typescript@5.8.3))': dependencies: '@antfu/utils': 0.7.10 @@ -20277,18 +20220,6 @@ snapshots: dependencies: '@vue/devtools-kit': 8.0.1 - '@vue/devtools-core@7.6.8(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1))(vue@3.5.13(typescript@5.8.3))': - dependencies: - '@vue/devtools-kit': 7.6.8 - '@vue/devtools-shared': 7.7.7 - mitt: 3.0.1 - nanoid: 5.1.5 - pathe: 1.1.2 - vite-hot-client: 0.2.4(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)) - vue: 3.5.13(typescript@5.8.3) - transitivePeerDependencies: - - vite - '@vue/devtools-core@7.6.8(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0))(vue@3.5.13(typescript@5.8.3))': dependencies: '@vue/devtools-kit': 7.6.8 @@ -20890,7 +20821,7 @@ snapshots: axios@1.8.2: dependencies: - follow-redirects: 1.15.11 + follow-redirects: 1.15.11(debug@4.4.1) form-data: 4.0.4 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -22315,7 +22246,7 @@ snapshots: eslint: 9.17.0(jiti@2.5.1) eslint-import-resolver-node: 0.3.9 eslint-import-resolver-typescript: 3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint@9.17.0(jiti@2.5.1)))(eslint@9.17.0(jiti@2.5.1)) - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint@9.17.0(jiti@2.5.1)))(eslint@9.17.0(jiti@2.5.1)))(eslint@9.17.0(jiti@2.5.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.17.0(jiti@2.5.1)) eslint-plugin-jsx-a11y: 6.10.2(eslint@9.17.0(jiti@2.5.1)) eslint-plugin-react: 7.37.5(eslint@9.17.0(jiti@2.5.1)) eslint-plugin-react-hooks: 5.2.0(eslint@9.17.0(jiti@2.5.1)) @@ -22349,7 +22280,7 @@ snapshots: tinyglobby: 0.2.14 unrs-resolver: 1.11.1 optionalDependencies: - eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint@9.17.0(jiti@2.5.1)))(eslint@9.17.0(jiti@2.5.1)))(eslint@9.17.0(jiti@2.5.1)) + eslint-plugin-import: 2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.17.0(jiti@2.5.1)) transitivePeerDependencies: - supports-color @@ -22364,7 +22295,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1(eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint@9.17.0(jiti@2.5.1)))(eslint@9.17.0(jiti@2.5.1)))(eslint@9.17.0(jiti@2.5.1)): + eslint-plugin-import@2.32.0(@typescript-eslint/parser@8.29.1(eslint@9.17.0(jiti@2.5.1))(typescript@5.8.3))(eslint-import-resolver-typescript@3.10.1)(eslint@9.17.0(jiti@2.5.1)): dependencies: '@rtsao/scc': 1.1.0 array-includes: 3.1.9 @@ -22974,8 +22905,6 @@ snapshots: dependencies: tabbable: 6.2.0 - follow-redirects@1.15.11: {} - follow-redirects@1.15.11(debug@4.4.1): optionalDependencies: debug: 4.4.1 @@ -25249,127 +25178,6 @@ snapshots: - vue-tsc - xml2js - nuxt@3.14.1592(@netlify/blobs@9.1.2)(@parcel/watcher@2.5.1)(@types/node@22.10.5)(db0@0.3.2)(encoding@0.1.13)(eslint@9.17.0(jiti@2.5.1))(ioredis@5.7.0)(less@4.2.2)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.50.0)(sass@1.85.0)(terser@5.43.1)(typescript@5.8.3)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)): - dependencies: - '@nuxt/devalue': 2.0.2 - '@nuxt/devtools': 1.7.0(rollup@4.50.0)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1))(vue@3.5.13(typescript@5.8.3)) - '@nuxt/kit': 3.14.1592(magicast@0.3.5)(rollup@4.50.0) - '@nuxt/schema': 3.14.1592(magicast@0.3.5)(rollup@4.50.0) - '@nuxt/telemetry': 2.6.6(magicast@0.3.5) - '@nuxt/vite-builder': 3.14.1592(@types/node@22.10.5)(eslint@9.17.0(jiti@2.5.1))(less@4.2.2)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.50.0)(sass@1.85.0)(terser@5.43.1)(typescript@5.8.3)(vue@3.5.13(typescript@5.8.3)) - '@unhead/dom': 1.11.20 - '@unhead/shared': 1.11.20 - '@unhead/ssr': 1.11.20 - '@unhead/vue': 1.11.20(vue@3.5.13(typescript@5.8.3)) - '@vue/shared': 3.5.20 - acorn: 8.14.0 - c12: 2.0.1(magicast@0.3.5) - chokidar: 4.0.3 - compatx: 0.1.8 - consola: 3.4.2 - cookie-es: 1.2.2 - defu: 6.1.4 - destr: 2.0.5 - devalue: 5.3.2 - errx: 0.1.0 - esbuild: 0.24.2 - escape-string-regexp: 5.0.0 - estree-walker: 3.0.3 - globby: 14.1.0 - h3: 1.15.4 - hookable: 5.5.3 - ignore: 6.0.2 - impound: 0.2.2(rollup@4.50.0) - jiti: 2.5.1 - klona: 2.0.6 - knitwork: 1.2.0 - magic-string: 0.30.18 - mlly: 1.7.4 - nanotar: 0.1.1 - nitropack: 2.12.4(@netlify/blobs@9.1.2)(encoding@0.1.13) - nuxi: 3.28.0 - nypm: 0.3.12 - ofetch: 1.4.1 - ohash: 1.1.6 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - pkg-types: 1.3.1 - radix3: 1.1.2 - scule: 1.3.0 - semver: 7.7.2 - std-env: 3.9.0 - strip-literal: 2.1.1 - tinyglobby: 0.2.10 - ufo: 1.6.1 - ultrahtml: 1.6.0 - uncrypto: 0.1.3 - unctx: 2.4.1 - unenv: 1.10.0 - unhead: 1.11.20 - unimport: 3.14.6(rollup@4.50.0) - unplugin: 1.16.1 - unplugin-vue-router: 0.10.9(rollup@4.50.0)(vue-router@4.5.0(vue@3.5.13(typescript@5.8.3)))(vue@3.5.13(typescript@5.8.3)) - unstorage: 1.17.0(@netlify/blobs@9.1.2)(db0@0.3.2)(ioredis@5.7.0) - untyped: 1.5.2 - vue: 3.5.13(typescript@5.8.3) - vue-bundle-renderer: 2.1.2 - vue-devtools-stub: 0.1.0 - vue-router: 4.5.0(vue@3.5.13(typescript@5.8.3)) - optionalDependencies: - '@parcel/watcher': 2.5.1 - '@types/node': 22.10.5 - transitivePeerDependencies: - - '@azure/app-configuration' - - '@azure/cosmos' - - '@azure/data-tables' - - '@azure/identity' - - '@azure/keyvault-secrets' - - '@azure/storage-blob' - - '@biomejs/biome' - - '@capacitor/preferences' - - '@deno/kv' - - '@electric-sql/pglite' - - '@libsql/client' - - '@netlify/blobs' - - '@planetscale/database' - - '@upstash/redis' - - '@vercel/blob' - - '@vercel/functions' - - '@vercel/kv' - - aws4fetch - - better-sqlite3 - - bufferutil - - db0 - - drizzle-orm - - encoding - - eslint - - idb-keyval - - ioredis - - less - - lightningcss - - magicast - - meow - - mysql2 - - optionator - - rolldown - - rollup - - sass - - sass-embedded - - sqlite3 - - stylelint - - stylus - - sugarss - - supports-color - - terser - - typescript - - uploadthing - - utf-8-validate - - vite - - vls - - vti - - vue-tsc - - xml2js - nuxt@3.14.1592(@netlify/blobs@9.1.2)(@parcel/watcher@2.5.1)(@types/node@22.10.5)(db0@0.3.2)(encoding@0.1.13)(eslint@9.17.0(jiti@2.5.1))(ioredis@5.7.0)(less@4.2.2)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.50.0)(sass@1.85.0)(terser@5.43.1)(typescript@5.8.3)(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0)): dependencies: '@nuxt/devalue': 2.0.2 @@ -28453,10 +28261,6 @@ snapshots: '@types/unist': 3.0.3 vfile-message: 4.0.3 - vite-hot-client@0.2.4(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)): - dependencies: - vite: 5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1) - vite-hot-client@0.2.4(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0)): dependencies: vite: 7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0) @@ -28587,24 +28391,6 @@ snapshots: - rollup - supports-color - vite-plugin-inspect@0.8.9(@nuxt/kit@3.15.4(magicast@0.3.5))(rollup@4.50.0)(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)): - dependencies: - '@antfu/utils': 0.7.10 - '@rollup/pluginutils': 5.2.0(rollup@4.50.0) - debug: 4.4.1 - error-stack-parser-es: 0.1.5 - fs-extra: 11.3.1 - open: 10.1.2 - perfect-debounce: 1.0.0 - picocolors: 1.1.1 - sirv: 3.0.1 - vite: 5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1) - optionalDependencies: - '@nuxt/kit': 3.15.4(magicast@0.3.5) - transitivePeerDependencies: - - rollup - - supports-color - vite-plugin-inspect@0.8.9(@nuxt/kit@3.15.4(magicast@0.3.5))(rollup@4.50.0)(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0)): dependencies: '@antfu/utils': 0.7.10 @@ -28639,21 +28425,6 @@ snapshots: - supports-color - vue - vite-plugin-vue-inspector@5.3.2(vite@5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)): - dependencies: - '@babel/core': 7.28.3 - '@babel/plugin-proposal-decorators': 7.28.0(@babel/core@7.28.3) - '@babel/plugin-syntax-import-attributes': 7.27.1(@babel/core@7.28.3) - '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.28.3) - '@babel/plugin-transform-typescript': 7.28.0(@babel/core@7.28.3) - '@vue/babel-plugin-jsx': 1.5.0(@babel/core@7.28.3) - '@vue/compiler-dom': 3.5.20 - kolorist: 1.8.0 - magic-string: 0.30.18 - vite: 5.4.19(@types/node@22.10.5)(less@4.2.2)(sass@1.85.0)(terser@5.43.1) - transitivePeerDependencies: - - supports-color - vite-plugin-vue-inspector@5.3.2(vite@7.1.2(@types/node@22.10.5)(jiti@2.5.1)(less@4.2.2)(sass@1.85.0)(terser@5.43.1)(yaml@2.8.0)): dependencies: '@babel/core': 7.28.3 -- 2.51.2 From d98e6fcf7da138269ff6d3927032f4bdea2d6480 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 20:01:33 +0800 Subject: [PATCH 04/19] chore: add readme to files for published packages --- packages/codegen-core/package.json | 3 ++- packages/nuxt/package.json | 2 +- packages/openapi-ts/package.json | 3 ++- packages/vite-plugin/package.json | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/codegen-core/package.json b/packages/codegen-core/package.json index de2c656e7..985202982 100644 --- a/packages/codegen-core/package.json +++ b/packages/codegen-core/package.json @@ -43,7 +43,8 @@ }, "files": [ "dist", - "LICENSE.md" + "LICENSE.md", + "README.md" ], "scripts": { "build": "tsup && pnpm check-exports", diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 4d69510aa..6d19dc5c7 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -44,7 +44,7 @@ "files": [ "dist", "LICENSE.md", - "src" + "README.md" ], "scripts": { "build": "nuxt-module-build build", diff --git a/packages/openapi-ts/package.json b/packages/openapi-ts/package.json index 0efd71b5f..0dba90302 100644 --- a/packages/openapi-ts/package.json +++ b/packages/openapi-ts/package.json @@ -70,7 +70,8 @@ "files": [ "bin", "dist", - "LICENSE.md" + "LICENSE.md", + "README.md" ], "scripts": { "build": "tsup && pnpm check-exports", diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index c9c21b462..3bd03c09f 100644 --- a/packages/vite-plugin/package.json +++ b/packages/vite-plugin/package.json @@ -44,7 +44,8 @@ }, "files": [ "dist", - "LICENSE.md" + "LICENSE.md", + "README.md" ], "scripts": { "build": "tsup && pnpm check-exports", -- 2.51.2 From 1193c4dce77e0cb02c32b25661f22065a18bd095 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 20:12:55 +0800 Subject: [PATCH 05/19] fix(config): correctly load user-defined hooks --- .changeset/odd-fireants-lay.md | 5 +++++ .../main/test/openapi-ts.config.ts | 16 ++++++++++++++-- packages/openapi-ts/src/config/parser.ts | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changeset/odd-fireants-lay.md diff --git a/.changeset/odd-fireants-lay.md b/.changeset/odd-fireants-lay.md new file mode 100644 index 000000000..3fa74523f --- /dev/null +++ b/.changeset/odd-fireants-lay.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(config): correctly load user-defined hooks 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 3c31fd029..95aa64e58 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -36,9 +36,9 @@ export default defineConfig(() => { '3.1.x', // 'invalid', // 'openai.yaml', - // 'full.yaml', + 'full.yaml', // 'opencode.yaml', - 'sdk-instance.yaml', + // 'sdk-instance.yaml', // 'validators-circular-ref-2.yaml', // 'zoom-video-sdk.json', ), @@ -98,6 +98,12 @@ export default defineConfig(() => { }, hooks: { operations: { + getKind() { + // noop + }, + isMutation() { + // noop + }, isQuery: (op) => { if (op.method === 'post' && op.path === '/search') { return true; @@ -227,6 +233,12 @@ export default defineConfig(() => { } return undefined; }, + isMutation() { + // noop + }, + isQuery: () => { + // noop + }, }, }, }, diff --git a/packages/openapi-ts/src/config/parser.ts b/packages/openapi-ts/src/config/parser.ts index 66e491486..2e9328ecc 100644 --- a/packages/openapi-ts/src/config/parser.ts +++ b/packages/openapi-ts/src/config/parser.ts @@ -40,6 +40,10 @@ export const getParser = (userConfig: UserConfig): Config['parser'] => { }; if (userConfig.parser) { + if (userConfig.parser.hooks) { + parser.hooks = userConfig.parser.hooks; + } + if (userConfig.parser.pagination?.keywords) { parser.pagination.keywords = userConfig.parser.pagination.keywords; } -- 2.51.2 From 4d73936137ca8aa286499778b2d51a765edffa69 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 21:16:39 +0800 Subject: [PATCH 06/19] fix(client): expose all interceptor methods --- packages/custom-client/src/client.ts | 6 +- packages/custom-client/src/utils.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../2.0.x/form-data/client/client.gen.ts | 8 +-- .../2.0.x/form-data/client/utils.gen.ts | 72 +++++++++---------- .../common/default-class/client/client.gen.ts | 6 +- .../common/default-class/client/utils.gen.ts | 72 +++++++++---------- .../common/default/client/client.gen.ts | 6 +- .../common/default/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../sdk-nested-classes/client/client.gen.ts | 8 +-- .../sdk-nested-classes/client/utils.gen.ts | 72 +++++++++---------- .../@hey-api/sdk/default/client/client.gen.ts | 8 +-- .../@hey-api/sdk/default/client/utils.gen.ts | 72 +++++++++---------- .../sdk/instance/client/client.gen.ts | 8 +-- .../@hey-api/sdk/instance/client/utils.gen.ts | 72 +++++++++---------- .../sdk/throwOnError/client/client.gen.ts | 8 +-- .../sdk/throwOnError/client/utils.gen.ts | 72 +++++++++---------- .../type-format-valibot/client/client.gen.ts | 8 +-- .../type-format-valibot/client/utils.gen.ts | 72 +++++++++---------- .../type-format-zod/client/client.gen.ts | 8 +-- .../type-format-zod/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../colada/asClass/client/client.gen.ts | 8 +-- .../@pinia/colada/asClass/client/utils.gen.ts | 72 +++++++++---------- .../@pinia/colada/fetch/client/client.gen.ts | 8 +-- .../@pinia/colada/fetch/client/utils.gen.ts | 72 +++++++++---------- .../asClass/client/client.gen.ts | 8 +-- .../asClass/client/utils.gen.ts | 72 +++++++++---------- .../fetch/client/client.gen.ts | 8 +-- .../fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../react-query/asClass/client/client.gen.ts | 8 +-- .../react-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../react-query/fetch/client/client.gen.ts | 8 +-- .../react-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../solid-query/asClass/client/client.gen.ts | 8 +-- .../solid-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../solid-query/fetch/client/client.gen.ts | 8 +-- .../solid-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../svelte-query/asClass/client/client.gen.ts | 8 +-- .../svelte-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../svelte-query/fetch/client/client.gen.ts | 8 +-- .../svelte-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../vue-query/asClass/client/client.gen.ts | 8 +-- .../vue-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../vue-query/fetch/client/client.gen.ts | 8 +-- .../vue-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../2.0.x/schema-unknown/client/client.gen.ts | 8 +-- .../2.0.x/schema-unknown/client/utils.gen.ts | 72 +++++++++---------- .../security-api-key/client/client.gen.ts | 8 +-- .../security-api-key/client/utils.gen.ts | 72 +++++++++---------- .../2.0.x/security-basic/client/client.gen.ts | 8 +-- .../2.0.x/security-basic/client/utils.gen.ts | 72 +++++++++---------- .../2.0.x/security-false/client/client.gen.ts | 8 +-- .../2.0.x/security-false/client/utils.gen.ts | 72 +++++++++---------- .../security-oauth2/client/client.gen.ts | 8 +-- .../2.0.x/security-oauth2/client/utils.gen.ts | 72 +++++++++---------- .../servers-base-path/client/client.gen.ts | 8 +-- .../servers-base-path/client/utils.gen.ts | 72 +++++++++---------- .../2.0.x/servers-host/client/client.gen.ts | 8 +-- .../2.0.x/servers-host/client/utils.gen.ts | 72 +++++++++---------- .../2.0.x/servers/client/client.gen.ts | 8 +-- .../2.0.x/servers/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../transforms-read-write/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../common/default-class/client/client.gen.ts | 6 +- .../common/default-class/client/utils.gen.ts | 72 +++++++++---------- .../common/default/client/client.gen.ts | 6 +- .../common/default/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../sdk-nested-classes/client/client.gen.ts | 8 +-- .../sdk-nested-classes/client/utils.gen.ts | 72 +++++++++---------- .../@hey-api/sdk/default/client/client.gen.ts | 8 +-- .../@hey-api/sdk/default/client/utils.gen.ts | 72 +++++++++---------- .../sdk/instance/client/client.gen.ts | 8 +-- .../@hey-api/sdk/instance/client/utils.gen.ts | 72 +++++++++---------- .../sdk/throwOnError/client/client.gen.ts | 8 +-- .../sdk/throwOnError/client/utils.gen.ts | 72 +++++++++---------- .../type-format-valibot/client/client.gen.ts | 8 +-- .../type-format-valibot/client/utils.gen.ts | 72 +++++++++---------- .../type-format-zod/client/client.gen.ts | 8 +-- .../type-format-zod/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../colada/asClass/client/client.gen.ts | 8 +-- .../@pinia/colada/asClass/client/utils.gen.ts | 72 +++++++++---------- .../@pinia/colada/fetch/client/client.gen.ts | 8 +-- .../@pinia/colada/fetch/client/utils.gen.ts | 72 +++++++++---------- .../asClass/client/client.gen.ts | 8 +-- .../asClass/client/utils.gen.ts | 72 +++++++++---------- .../fetch/client/client.gen.ts | 8 +-- .../fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../react-query/asClass/client/client.gen.ts | 8 +-- .../react-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../react-query/fetch/client/client.gen.ts | 8 +-- .../react-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../solid-query/asClass/client/client.gen.ts | 8 +-- .../solid-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../solid-query/fetch/client/client.gen.ts | 8 +-- .../solid-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../svelte-query/asClass/client/client.gen.ts | 8 +-- .../svelte-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../svelte-query/fetch/client/client.gen.ts | 8 +-- .../svelte-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../vue-query/asClass/client/client.gen.ts | 8 +-- .../vue-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../vue-query/fetch/client/client.gen.ts | 8 +-- .../vue-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../security-api-key/client/client.gen.ts | 8 +-- .../security-api-key/client/utils.gen.ts | 72 +++++++++---------- .../3.0.x/security-false/client/client.gen.ts | 8 +-- .../3.0.x/security-false/client/utils.gen.ts | 72 +++++++++---------- .../security-http-bearer/client/client.gen.ts | 8 +-- .../security-http-bearer/client/utils.gen.ts | 72 +++++++++---------- .../security-oauth2/client/client.gen.ts | 8 +-- .../3.0.x/security-oauth2/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../3.0.x/servers/client/client.gen.ts | 8 +-- .../3.0.x/servers/client/utils.gen.ts | 72 +++++++++---------- .../transformers-all-of/client/client.gen.ts | 8 +-- .../transformers-all-of/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../transformers-array/client/client.gen.ts | 8 +-- .../transformers-array/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../transforms-read-write/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../base-url-false/client/client.gen.ts | 8 +-- .../base-url-false/client/utils.gen.ts | 72 +++++++++---------- .../base-url-number/client/client.gen.ts | 8 +-- .../base-url-number/client/utils.gen.ts | 72 +++++++++---------- .../base-url-strict/client/client.gen.ts | 8 +-- .../base-url-strict/client/utils.gen.ts | 72 +++++++++---------- .../base-url-string/client/client.gen.ts | 8 +-- .../base-url-string/client/utils.gen.ts | 72 +++++++++---------- .../clean-false/client/client.gen.ts | 8 +-- .../clean-false/client/utils.gen.ts | 72 +++++++++---------- .../client-fetch/default/client/client.gen.ts | 8 +-- .../client-fetch/default/client/utils.gen.ts | 72 +++++++++---------- .../sdk-client-optional/client/client.gen.ts | 8 +-- .../sdk-client-optional/client/utils.gen.ts | 72 +++++++++---------- .../sdk-client-required/client/client.gen.ts | 8 +-- .../sdk-client-required/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../tsconfig-nodenext-sdk/client/utils.gen.ts | 72 +++++++++---------- .../base-url-false/client/client.gen.ts | 8 +-- .../base-url-false/client/utils.gen.ts | 65 +++++++++-------- .../base-url-number/client/client.gen.ts | 8 +-- .../base-url-number/client/utils.gen.ts | 65 +++++++++-------- .../base-url-strict/client/client.gen.ts | 8 +-- .../base-url-strict/client/utils.gen.ts | 65 +++++++++-------- .../base-url-string/client/client.gen.ts | 8 +-- .../base-url-string/client/utils.gen.ts | 65 +++++++++-------- .../clean-false/client/client.gen.ts | 8 +-- .../clean-false/client/utils.gen.ts | 65 +++++++++-------- .../client-next/default/client/client.gen.ts | 8 +-- .../client-next/default/client/utils.gen.ts | 65 +++++++++-------- .../sdk-client-optional/client/client.gen.ts | 8 +-- .../sdk-client-optional/client/utils.gen.ts | 65 +++++++++-------- .../sdk-client-required/client/client.gen.ts | 8 +-- .../sdk-client-required/client/utils.gen.ts | 65 +++++++++-------- .../client/client.gen.ts | 8 +-- .../tsconfig-nodenext-sdk/client/utils.gen.ts | 65 +++++++++-------- .../client-custom/bundle/client/index.cjs | 2 +- .../client-custom/bundle/client/index.d.cts | 15 ++-- .../client-custom/bundle/client/index.d.ts | 15 ++-- .../my-client/base-url-false/client/client.ts | 18 +++-- .../my-client/base-url-false/client/utils.ts | 65 ++++++++++------- .../base-url-number/client/client.ts | 18 +++-- .../my-client/base-url-number/client/utils.ts | 65 ++++++++++------- .../base-url-strict/client/client.ts | 18 +++-- .../my-client/base-url-strict/client/utils.ts | 65 ++++++++++------- .../base-url-string/client/client.ts | 18 +++-- .../my-client/base-url-string/client/utils.ts | 65 ++++++++++------- .../clients/my-client/bundle/client/client.ts | 18 +++-- .../clients/my-client/bundle/client/utils.ts | 65 ++++++++++------- .../my-client/default/client/client.ts | 18 +++-- .../clients/my-client/default/client/utils.ts | 65 ++++++++++------- .../sdk-client-optional/client/client.ts | 18 +++-- .../sdk-client-optional/client/utils.ts | 65 ++++++++++------- .../sdk-client-required/client/client.ts | 18 +++-- .../sdk-client-required/client/utils.ts | 65 ++++++++++------- .../3.1.x/headers/client/client.gen.ts | 8 +-- .../3.1.x/headers/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../3.1.x/pagination-ref/client/client.gen.ts | 8 +-- .../3.1.x/pagination-ref/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../common/default-class/client/client.gen.ts | 6 +- .../common/default-class/client/utils.gen.ts | 72 +++++++++---------- .../common/default/client/client.gen.ts | 6 +- .../common/default/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../sdk-nested-classes/client/client.gen.ts | 8 +-- .../sdk-nested-classes/client/utils.gen.ts | 72 +++++++++---------- .../@hey-api/sdk/default/client/client.gen.ts | 8 +-- .../@hey-api/sdk/default/client/utils.gen.ts | 72 +++++++++---------- .../sdk/instance/client/client.gen.ts | 8 +-- .../@hey-api/sdk/instance/client/utils.gen.ts | 72 +++++++++---------- .../sdk/throwOnError/client/client.gen.ts | 8 +-- .../sdk/throwOnError/client/utils.gen.ts | 72 +++++++++---------- .../type-format-valibot/client/client.gen.ts | 8 +-- .../type-format-valibot/client/utils.gen.ts | 72 +++++++++---------- .../type-format-zod/client/client.gen.ts | 8 +-- .../type-format-zod/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../colada/asClass/client/client.gen.ts | 8 +-- .../@pinia/colada/asClass/client/utils.gen.ts | 72 +++++++++---------- .../@pinia/colada/fetch/client/client.gen.ts | 8 +-- .../@pinia/colada/fetch/client/utils.gen.ts | 72 +++++++++---------- .../asClass/client/client.gen.ts | 8 +-- .../asClass/client/utils.gen.ts | 72 +++++++++---------- .../fetch/client/client.gen.ts | 8 +-- .../fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../react-query/asClass/client/client.gen.ts | 8 +-- .../react-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../react-query/fetch/client/client.gen.ts | 8 +-- .../react-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../solid-query/asClass/client/client.gen.ts | 8 +-- .../solid-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../solid-query/fetch/client/client.gen.ts | 8 +-- .../solid-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../svelte-query/asClass/client/client.gen.ts | 8 +-- .../svelte-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../svelte-query/fetch/client/client.gen.ts | 8 +-- .../svelte-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../vue-query/asClass/client/client.gen.ts | 8 +-- .../vue-query/asClass/client/utils.gen.ts | 72 +++++++++---------- .../vue-query/fetch/client/client.gen.ts | 8 +-- .../vue-query/fetch/client/utils.gen.ts | 72 +++++++++---------- .../name-builder/client/client.gen.ts | 8 +-- .../name-builder/client/utils.gen.ts | 72 +++++++++---------- .../security-api-key/client/client.gen.ts | 8 +-- .../security-api-key/client/utils.gen.ts | 72 +++++++++---------- .../3.1.x/security-false/client/client.gen.ts | 8 +-- .../3.1.x/security-false/client/utils.gen.ts | 72 +++++++++---------- .../security-http-bearer/client/client.gen.ts | 8 +-- .../security-http-bearer/client/utils.gen.ts | 72 +++++++++---------- .../security-oauth2/client/client.gen.ts | 8 +-- .../3.1.x/security-oauth2/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../3.1.x/servers/client/client.gen.ts | 8 +-- .../3.1.x/servers/client/utils.gen.ts | 72 +++++++++---------- .../3.1.x/sse-angular/client/client.gen.ts | 6 +- .../3.1.x/sse-angular/client/utils.gen.ts | 72 +++++++++---------- .../3.1.x/sse-fetch/client/client.gen.ts | 8 +-- .../3.1.x/sse-fetch/client/utils.gen.ts | 72 +++++++++---------- .../3.1.x/sse-next/client/client.gen.ts | 8 +-- .../3.1.x/sse-next/client/utils.gen.ts | 65 +++++++++-------- .../transformers-all-of/client/client.gen.ts | 8 +-- .../transformers-all-of/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../client/utils.gen.ts | 72 +++++++++---------- .../transformers-array/client/client.gen.ts | 8 +-- .../transformers-array/client/utils.gen.ts | 72 +++++++++---------- .../client/client.gen.ts | 8 +-- .../transforms-read-write/client/utils.gen.ts | 72 +++++++++---------- .../@tanstack/meta/client/client.gen.ts | 8 +-- .../@tanstack/meta/client/utils.gen.ts | 72 +++++++++---------- .../v3_no_index/client/client.gen.ts.snap | 8 +-- .../v3_no_index/client/utils.gen.ts.snap | 72 +++++++++---------- .../main/test/custom/client/client.ts | 18 +++-- .../main/test/custom/client/utils.ts | 65 ++++++++++------- .../@hey-api/client-angular/bundle/client.ts | 6 +- .../@hey-api/client-angular/bundle/utils.ts | 72 +++++++++---------- .../@hey-api/client-fetch/bundle/client.ts | 8 +-- .../@hey-api/client-fetch/bundle/utils.ts | 72 +++++++++---------- .../@hey-api/client-next/bundle/client.ts | 8 +-- .../@hey-api/client-next/bundle/utils.ts | 65 +++++++++-------- 321 files changed, 6004 insertions(+), 6680 deletions(-) diff --git a/packages/custom-client/src/client.ts b/packages/custom-client/src/client.ts index 491eab1f6..2a5af631a 100644 --- a/packages/custom-client/src/client.ts +++ b/packages/custom-client/src/client.ts @@ -68,7 +68,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -147,7 +147,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } diff --git a/packages/custom-client/src/utils.ts b/packages/custom-client/src/utils.ts index e3a448443..7dcdf3765 100644 --- a/packages/custom-client/src/utils.ts +++ b/packages/custom-client/src/utils.ts @@ -345,67 +345,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), 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 index 40c2b65df..1555ca230 100644 --- 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 @@ -131,7 +131,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -152,7 +152,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -178,7 +178,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, 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 index 3bb799dff..200bb2941 100644 --- 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 @@ -340,67 +340,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), 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 index 40c2b65df..1555ca230 100644 --- 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 @@ -131,7 +131,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -152,7 +152,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -178,7 +178,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, 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 index 3bb799dff..200bb2941 100644 --- 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 @@ -340,67 +340,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } 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 index b9ec3cdd6..b4bcc4d19 100644 --- 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 @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), 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 index 40c2b65df..1555ca230 100644 --- 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 @@ -131,7 +131,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -152,7 +152,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -178,7 +178,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, 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 index 3bb799dff..200bb2941 100644 --- 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 @@ -340,67 +340,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), 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 index 40c2b65df..1555ca230 100644 --- 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 @@ -131,7 +131,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -152,7 +152,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -178,7 +178,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, 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 index 3bb799dff..200bb2941 100644 --- 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 @@ -340,67 +340,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } 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 index b9ec3cdd6..b4bcc4d19 100644 --- 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 @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts index abde5f47a..67961302b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/utils.gen.ts index 369894f5d..48f1c9738 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts index 9b64299f0..12468638a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/utils.gen.ts index 98945a49d..3e5473d06 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.cjs b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.cjs index 897f77d7f..9df7db9ac 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.cjs +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.cjs @@ -1,2 +1,2 @@ -'use strict';var A=async(t,r)=>{let e=typeof r=="function"?await r(t):r;if(e)return t.scheme==="bearer"?`Bearer ${e}`:t.scheme==="basic"?`Basic ${btoa(e)}`:e};var w=(t,r,e)=>{typeof e=="string"||e instanceof Blob?t.append(r,e):t.append(r,JSON.stringify(e));},P=(t,r,e)=>{typeof e=="string"?t.append(r,e):t.append(r,JSON.stringify(e));},_={bodySerializer:t=>{let r=new FormData;return Object.entries(t).forEach(([e,o])=>{o!=null&&(Array.isArray(o)?o.forEach(s=>w(r,e,s)):w(r,e,o));}),r}},x={bodySerializer:t=>JSON.stringify(t,(r,e)=>typeof e=="bigint"?e.toString():e)},U={bodySerializer:t=>{let r=new URLSearchParams;return Object.entries(t).forEach(([e,o])=>{o!=null&&(Array.isArray(o)?o.forEach(s=>P(r,e,s)):P(r,e,o));}),r.toString()}};var D=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},F=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},M=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:t,explode:r,name:e,style:o,value:s})=>{if(!r){let n=(t?s:s.map(c=>encodeURIComponent(c))).join(F(o));switch(o){case "label":return `.${n}`;case "matrix":return `;${e}=${n}`;case "simple":return n;default:return `${e}=${n}`}}let a=D(o),i=s.map(n=>o==="label"||o==="simple"?t?n:encodeURIComponent(n):m({allowReserved:t,name:e,value:n})).join(a);return o==="label"||o==="matrix"?a+i:i},m=({allowReserved:t,name:r,value:e})=>{if(e==null)return "";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${t?e:encodeURIComponent(e)}`},R=({allowReserved:t,explode:r,name:e,style:o,value:s,valueOnly:a})=>{if(s instanceof Date)return a?s.toISOString():`${e}=${s.toISOString()}`;if(o!=="deepObject"&&!r){let c=[];Object.entries(s).forEach(([f,d])=>{c=[...c,f,t?d:encodeURIComponent(d)];});let p=c.join(",");switch(o){case "form":return `${e}=${p}`;case "label":return `.${p}`;case "matrix":return `;${e}=${p}`;default:return p}}let i=M(o),n=Object.entries(s).map(([c,p])=>m({allowReserved:t,name:o==="deepObject"?`${e}[${c}]`:c,value:p})).join(i);return o==="label"||o==="matrix"?i+n:n};var H=/\{[^{}]+\}/g,B=({path:t,url:r})=>{let e=r,o=r.match(H);if(o)for(let s of o){let a=false,i=s.substring(1,s.length-1),n="simple";i.endsWith("*")&&(a=true,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),n="label"):i.startsWith(";")&&(i=i.substring(1),n="matrix");let c=t[i];if(c==null)continue;if(Array.isArray(c)){e=e.replace(s,O({explode:a,name:i,style:n,value:c}));continue}if(typeof c=="object"){e=e.replace(s,R({explode:a,name:i,style:n,value:c,valueOnly:true}));continue}if(n==="matrix"){e=e.replace(s,`;${m({name:i,value:c})}`);continue}let p=encodeURIComponent(n==="label"?`.${c}`:c);e=e.replace(s,p);}return e},k=({allowReserved:t,array:r,object:e}={})=>s=>{let a=[];if(s&&typeof s=="object")for(let i in s){let n=s[i];if(n!=null)if(Array.isArray(n)){let c=O({allowReserved:t,explode:true,name:i,style:"form",value:n,...r});c&&a.push(c);}else if(typeof n=="object"){let c=R({allowReserved:t,explode:true,name:i,style:"deepObject",value:n,...e});c&&a.push(c);}else {let c=m({allowReserved:t,name:i,value:n});c&&a.push(c);}}return a.join("&")},I=t=>{if(!t)return "stream";let r=t.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},W=(t,r)=>r?!!(t.headers.has(r)||t.query?.[r]||t.headers.get("Cookie")?.includes(`${r}=`)):false,T=async({security:t,...r})=>{for(let e of t){if(W(r,e.name))continue;let o=await A(e,r.auth);if(!o)continue;let s=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[s]=o;break;case "cookie":r.headers.append("Cookie",`${s}=${o}`);break;case "header":default:r.headers.set(s,o);break}}},q=t=>N({baseUrl:t.baseUrl,path:t.path,query:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:k(t.querySerializer),url:t.url}),N=({baseUrl:t,path:r,query:e,querySerializer:o,url:s})=>{let a=s.startsWith("/")?s:`/${s}`,i=(t??"")+a;r&&(i=B({path:r,url:i}));let n=e?o(e):"";return n.startsWith("?")&&(n=n.substring(1)),n&&(i+=`?${n}`),i},z=(t,r)=>{let e={...t,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=C(t.headers,r.headers),e},C=(...t)=>{let r=new Headers;for(let e of t){if(!e||typeof e!="object")continue;let o=e instanceof Headers?e.entries():Object.entries(e);for(let[s,a]of o)if(a===null)r.delete(s);else if(Array.isArray(a))for(let i of a)r.append(s,i);else a!==void 0&&r.set(s,typeof a=="object"?JSON.stringify(a):a);}return r},g=class{_fns;constructor(){this._fns=[];}clear(){this._fns=[];}getInterceptorIndex(r){return typeof r=="number"?this._fns[r]?r:-1:this._fns.indexOf(r)}exists(r){let e=this.getInterceptorIndex(r);return !!this._fns[e]}eject(r){let e=this.getInterceptorIndex(r);this._fns[e]&&(this._fns[e]=null);}update(r,e){let o=this.getInterceptorIndex(r);return this._fns[o]?(this._fns[o]=e,r):false}use(r){return this._fns=[...this._fns,r],this._fns.length-1}},E=()=>({error:new g,request:new g,response:new g}),Q=k({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),V={"Content-Type":"application/json"},j=(t={})=>({...x,headers:V,parseAs:"auto",querySerializer:Q,...t});var J=(t={})=>{let r=z(j(),t),e=()=>({...r}),o=i=>(r=z(r,i),e()),s=E(),a=async i=>{let n={...r,...i,fetch:i.fetch??r.fetch??globalThis.fetch,headers:C(r.headers,i.headers)};n.security&&await T({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body&&n.bodySerializer&&(n.body=n.bodySerializer(n.body)),(n.body===void 0||n.body==="")&&n.headers.delete("Content-Type");let c=q(n),p={redirect:"follow",...n},f=new Request(c,p);for(let u of s.request._fns)u&&(f=await u(f,n));let d=n.fetch,l=await d(f);for(let u of s.response._fns)u&&(l=await u(l,f,n));let b={request:f,response:l};if(l.ok){if(l.status===204||l.headers.get("Content-Length")==="0")return {data:{},...b};let u=(n.parseAs==="auto"?I(l.headers.get("Content-Type")):n.parseAs)??"json",h;switch(u){case "arrayBuffer":case "blob":case "formData":case "json":case "text":h=await l[u]();break;case "stream":return {data:l.body,...b}}return u==="json"&&(n.responseValidator&&await n.responseValidator(h),n.responseTransformer&&(h=await n.responseTransformer(h))),{data:h,...b}}let S=await l.text();try{S=JSON.parse(S);}catch{}let y=S;for(let u of s.error._fns)u&&(y=await u(S,l,f,n));if(y=y||{},n.throwOnError)throw y;return {error:y,...b}};return {buildUrl:q,connect:i=>a({...i,method:"CONNECT"}),delete:i=>a({...i,method:"DELETE"}),get:i=>a({...i,method:"GET"}),getConfig:e,head:i=>a({...i,method:"HEAD"}),interceptors:s,options:i=>a({...i,method:"OPTIONS"}),patch:i=>a({...i,method:"PATCH"}),post:i=>a({...i,method:"POST"}),put:i=>a({...i,method:"PUT"}),request:a,setConfig:o,trace:i=>a({...i,method:"TRACE"})}};var K={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},L=Object.entries(K),$=(t,r)=>{r||(r=new Map);for(let e of t)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&$(e.args,r);return r},G=t=>{for(let[r,e]of Object.entries(t))e&&typeof e=="object"&&!Object.keys(e).length&&delete t[r];},v=(t,r)=>{let e={body:{},headers:{},path:{},query:{}},o=$(r),s;for(let[a,i]of t.entries())if(r[a]&&(s=r[a]),!!s)if("in"in s)if(s.key){let n=o.get(s.key),c=n.map||s.key;e[n.in][c]=i;}else e.body=i;else for(let[n,c]of Object.entries(i??{})){let p=o.get(n);if(p){let f=p.map||n;e[p.in][f]=c;}else {let f=L.find(([d])=>n.startsWith(d));if(f){let[d,l]=f;e[l][n.slice(d.length)]=c;}else for(let[d,l]of Object.entries(s.allowExtra??{}))if(l){e[d][n]=c;break}}}return G(e),e};exports.buildClientParams=v;exports.createClient=J;exports.createConfig=j;exports.formDataBodySerializer=_;exports.jsonBodySerializer=x;exports.urlSearchParamsBodySerializer=U;//# sourceMappingURL=index.cjs.map +'use strict';var w=async(t,r)=>{let e=typeof r=="function"?await r(t):r;if(e)return t.scheme==="bearer"?`Bearer ${e}`:t.scheme==="basic"?`Basic ${btoa(e)}`:e};var j=(t,r,e)=>{typeof e=="string"||e instanceof Blob?t.append(r,e):t.append(r,JSON.stringify(e));},P=(t,r,e)=>{typeof e=="string"?t.append(r,e):t.append(r,JSON.stringify(e));},U={bodySerializer:t=>{let r=new FormData;return Object.entries(t).forEach(([e,s])=>{s!=null&&(Array.isArray(s)?s.forEach(o=>j(r,e,o)):j(r,e,s));}),r}},x={bodySerializer:t=>JSON.stringify(t,(r,e)=>typeof e=="bigint"?e.toString():e)},D={bodySerializer:t=>{let r=new URLSearchParams;return Object.entries(t).forEach(([e,s])=>{s!=null&&(Array.isArray(s)?s.forEach(o=>P(r,e,o)):P(r,e,s));}),r.toString()}};var M=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},F=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},B=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},O=({allowReserved:t,explode:r,name:e,style:s,value:o})=>{if(!r){let n=(t?o:o.map(c=>encodeURIComponent(c))).join(F(s));switch(s){case "label":return `.${n}`;case "matrix":return `;${e}=${n}`;case "simple":return n;default:return `${e}=${n}`}}let a=M(s),i=o.map(n=>s==="label"||s==="simple"?t?n:encodeURIComponent(n):h({allowReserved:t,name:e,value:n})).join(a);return s==="label"||s==="matrix"?a+i:i},h=({allowReserved:t,name:r,value:e})=>{if(e==null)return "";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${t?e:encodeURIComponent(e)}`},R=({allowReserved:t,explode:r,name:e,style:s,value:o,valueOnly:a})=>{if(o instanceof Date)return a?o.toISOString():`${e}=${o.toISOString()}`;if(s!=="deepObject"&&!r){let c=[];Object.entries(o).forEach(([f,d])=>{c=[...c,f,t?d:encodeURIComponent(d)];});let p=c.join(",");switch(s){case "form":return `${e}=${p}`;case "label":return `.${p}`;case "matrix":return `;${e}=${p}`;default:return p}}let i=B(s),n=Object.entries(o).map(([c,p])=>h({allowReserved:t,name:s==="deepObject"?`${e}[${c}]`:c,value:p})).join(i);return s==="label"||s==="matrix"?i+n:n};var H=/\{[^{}]+\}/g,W=({path:t,url:r})=>{let e=r,s=r.match(H);if(s)for(let o of s){let a=false,i=o.substring(1,o.length-1),n="simple";i.endsWith("*")&&(a=true,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),n="label"):i.startsWith(";")&&(i=i.substring(1),n="matrix");let c=t[i];if(c==null)continue;if(Array.isArray(c)){e=e.replace(o,O({explode:a,name:i,style:n,value:c}));continue}if(typeof c=="object"){e=e.replace(o,R({explode:a,name:i,style:n,value:c,valueOnly:true}));continue}if(n==="matrix"){e=e.replace(o,`;${h({name:i,value:c})}`);continue}let p=encodeURIComponent(n==="label"?`.${c}`:c);e=e.replace(o,p);}return e},k=({allowReserved:t,array:r,object:e}={})=>o=>{let a=[];if(o&&typeof o=="object")for(let i in o){let n=o[i];if(n!=null)if(Array.isArray(n)){let c=O({allowReserved:t,explode:true,name:i,style:"form",value:n,...r});c&&a.push(c);}else if(typeof n=="object"){let c=R({allowReserved:t,explode:true,name:i,style:"deepObject",value:n,...e});c&&a.push(c);}else {let c=h({allowReserved:t,name:i,value:n});c&&a.push(c);}}return a.join("&")},I=t=>{if(!t)return "stream";let r=t.split(";")[0]?.trim();if(r){if(r.startsWith("application/json")||r.endsWith("+json"))return "json";if(r==="multipart/form-data")return "formData";if(["application/","audio/","image/","video/"].some(e=>r.startsWith(e)))return "blob";if(r.startsWith("text/"))return "text"}},N=(t,r)=>r?!!(t.headers.has(r)||t.query?.[r]||t.headers.get("Cookie")?.includes(`${r}=`)):false,T=async({security:t,...r})=>{for(let e of t){if(N(r,e.name))continue;let s=await w(e,r.auth);if(!s)continue;let o=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[o]=s;break;case "cookie":r.headers.append("Cookie",`${o}=${s}`);break;case "header":default:r.headers.set(o,s);break}}},q=t=>Q({baseUrl:t.baseUrl,path:t.path,query:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:k(t.querySerializer),url:t.url}),Q=({baseUrl:t,path:r,query:e,querySerializer:s,url:o})=>{let a=o.startsWith("/")?o:`/${o}`,i=(t??"")+a;r&&(i=W({path:r,url:i}));let n=e?s(e):"";return n.startsWith("?")&&(n=n.substring(1)),n&&(i+=`?${n}`),i},z=(t,r)=>{let e={...t,...r};return e.baseUrl?.endsWith("/")&&(e.baseUrl=e.baseUrl.substring(0,e.baseUrl.length-1)),e.headers=A(t.headers,r.headers),e},A=(...t)=>{let r=new Headers;for(let e of t){if(!e||typeof e!="object")continue;let s=e instanceof Headers?e.entries():Object.entries(e);for(let[o,a]of s)if(a===null)r.delete(o);else if(Array.isArray(a))for(let i of a)r.append(o,i);else a!==void 0&&r.set(o,typeof a=="object"?JSON.stringify(a):a);}return r},g=class{fns=[];clear(){this.fns=[];}eject(r){let e=this.getInterceptorIndex(r);this.fns[e]&&(this.fns[e]=null);}exists(r){let e=this.getInterceptorIndex(r);return !!this.fns[e]}getInterceptorIndex(r){return typeof r=="number"?this.fns[r]?r:-1:this.fns.indexOf(r)}update(r,e){let s=this.getInterceptorIndex(r);return this.fns[s]?(this.fns[s]=e,r):false}use(r){return this.fns.push(r),this.fns.length-1}},E=()=>({error:new g,request:new g,response:new g}),V=k({allowReserved:false,array:{explode:true,style:"form"},object:{explode:true,style:"deepObject"}}),_={"Content-Type":"application/json"},C=(t={})=>({...x,headers:_,parseAs:"auto",querySerializer:V,...t});var J=(t={})=>{let r=z(C(),t),e=()=>({...r}),s=i=>(r=z(r,i),e()),o=E(),a=async i=>{let n={...r,...i,fetch:i.fetch??r.fetch??globalThis.fetch,headers:A(r.headers,i.headers)};n.security&&await T({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body&&n.bodySerializer&&(n.body=n.bodySerializer(n.body)),(n.body===void 0||n.body==="")&&n.headers.delete("Content-Type");let c=q(n),p={redirect:"follow",...n},f=new Request(c,p);for(let u of o.request.fns)u&&(f=await u(f,n));let d=n.fetch,l=await d(f);for(let u of o.response.fns)u&&(l=await u(l,f,n));let b={request:f,response:l};if(l.ok){if(l.status===204||l.headers.get("Content-Length")==="0")return {data:{},...b};let u=(n.parseAs==="auto"?I(l.headers.get("Content-Type")):n.parseAs)??"json",m;switch(u){case "arrayBuffer":case "blob":case "formData":case "json":case "text":m=await l[u]();break;case "stream":return {data:l.body,...b}}return u==="json"&&(n.responseValidator&&await n.responseValidator(m),n.responseTransformer&&(m=await n.responseTransformer(m))),{data:m,...b}}let S=await l.text();try{S=JSON.parse(S);}catch{}let y=S;for(let u of o.error.fns)u&&(y=await u(S,l,f,n));if(y=y||{},n.throwOnError)throw y;return {error:y,...b}};return {buildUrl:q,connect:i=>a({...i,method:"CONNECT"}),delete:i=>a({...i,method:"DELETE"}),get:i=>a({...i,method:"GET"}),getConfig:e,head:i=>a({...i,method:"HEAD"}),interceptors:o,options:i=>a({...i,method:"OPTIONS"}),patch:i=>a({...i,method:"PATCH"}),post:i=>a({...i,method:"POST"}),put:i=>a({...i,method:"PUT"}),request:a,setConfig:s,trace:i=>a({...i,method:"TRACE"})}};var K={$body_:"body",$headers_:"headers",$path_:"path",$query_:"query"},L=Object.entries(K),$=(t,r)=>{r||(r=new Map);for(let e of t)"in"in e?e.key&&r.set(e.key,{in:e.in,map:e.map}):e.args&&$(e.args,r);return r},v=t=>{for(let[r,e]of Object.entries(t))e&&typeof e=="object"&&!Object.keys(e).length&&delete t[r];},G=(t,r)=>{let e={body:{},headers:{},path:{},query:{}},s=$(r),o;for(let[a,i]of t.entries())if(r[a]&&(o=r[a]),!!o)if("in"in o)if(o.key){let n=s.get(o.key),c=n.map||o.key;e[n.in][c]=i;}else e.body=i;else for(let[n,c]of Object.entries(i??{})){let p=s.get(n);if(p){let f=p.map||n;e[p.in][f]=c;}else {let f=L.find(([d])=>n.startsWith(d));if(f){let[d,l]=f;e[l][n.slice(d.length)]=c;}else for(let[d,l]of Object.entries(o.allowExtra??{}))if(l){e[d][n]=c;break}}}return v(e),e};exports.buildClientParams=G;exports.createClient=J;exports.createConfig=C;exports.formDataBodySerializer=U;exports.jsonBodySerializer=x;exports.urlSearchParamsBodySerializer=D;//# sourceMappingURL=index.cjs.map //# sourceMappingURL=index.cjs.map \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts index 05f9beb62..3abe6f94e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.cts @@ -119,19 +119,18 @@ type ErrInterceptor = (error: Err, response: Res, reques type ReqInterceptor = (request: Req, options: Options) => Req | Promise; type ResInterceptor = (response: Res, request: Req, options: Options) => Res | Promise; declare class Interceptors { - _fns: (Interceptor | null)[]; - constructor(); + fns: Array; clear(): void; - getInterceptorIndex(id: number | Interceptor): number; - exists(id: number | Interceptor): boolean; eject(id: number | Interceptor): void; - update(id: number | Interceptor, fn: Interceptor): number | false | Interceptor; + exists(id: number | Interceptor): boolean; + getInterceptorIndex(id: number | Interceptor): number; + update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; use(fn: Interceptor): number; } interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } declare const createConfig: (override?: Config & T>) => Config & T>; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.ts index 05f9beb62..3abe6f94e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client/index.d.ts @@ -119,19 +119,18 @@ type ErrInterceptor = (error: Err, response: Res, reques type ReqInterceptor = (request: Req, options: Options) => Req | Promise; type ResInterceptor = (response: Res, request: Req, options: Options) => Res | Promise; declare class Interceptors { - _fns: (Interceptor | null)[]; - constructor(); + fns: Array; clear(): void; - getInterceptorIndex(id: number | Interceptor): number; - exists(id: number | Interceptor): boolean; eject(id: number | Interceptor): void; - update(id: number | Interceptor, fn: Interceptor): number | false | Interceptor; + exists(id: number | Interceptor): boolean; + getInterceptorIndex(id: number | Interceptor): number; + update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false; use(fn: Interceptor): number; } interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } declare const createConfig: (override?: Config & T>) => Config & T>; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/client.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/client.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/utils.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), 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 index 40c2b65df..1555ca230 100644 --- 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 @@ -131,7 +131,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -152,7 +152,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -178,7 +178,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, 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 index 3bb799dff..200bb2941 100644 --- 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 @@ -340,67 +340,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), 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 index 40c2b65df..1555ca230 100644 --- 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 @@ -131,7 +131,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -152,7 +152,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -178,7 +178,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, 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 index 3bb799dff..200bb2941 100644 --- 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 @@ -340,67 +340,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } 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 index b9ec3cdd6..b4bcc4d19 100644 --- 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 @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts index 40c2b65df..1555ca230 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts @@ -131,7 +131,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -152,7 +152,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -178,7 +178,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts index 3bb799dff..200bb2941 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts @@ -340,67 +340,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts index 275d3501c..53d0433b9 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts @@ -79,7 +79,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -183,7 +183,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -220,7 +220,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/utils.gen.ts index f3cd764fc..d87d7af62 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/utils.gen.ts @@ -351,61 +351,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/utils.gen.ts index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/utils.gen.ts @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap index 6ed36fb89..a439d2748 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap @@ -86,7 +86,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -192,7 +192,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -227,7 +227,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/utils.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/utils.gen.ts.snap index b9ec3cdd6..b4bcc4d19 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/utils.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/utils.gen.ts.snap @@ -244,67 +244,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts-tests/main/test/custom/client/client.ts b/packages/openapi-ts-tests/main/test/custom/client/client.ts index 79e997eb7..53f568bff 100644 --- a/packages/openapi-ts-tests/main/test/custom/client/client.ts +++ b/packages/openapi-ts-tests/main/test/custom/client/client.ts @@ -64,8 +64,10 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { - request = await fn(request, opts); + 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: @@ -73,8 +75,10 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { - response = await fn(response, request, opts); + for (const fn of interceptors.response.fns) { + if (fn) { + response = await fn(response, request, opts); + } } const result = { @@ -132,8 +136,10 @@ export const createClient = (config: Config = {}): Client => { let finalError = error; - for (const fn of interceptors.error._fns) { - finalError = (await fn(error, response, request, opts)) as string; + for (const fn of interceptors.error.fns) { + if (fn) { + finalError = (await fn(error, response, request, opts)) as string; + } } finalError = finalError || ({} as string); diff --git a/packages/openapi-ts-tests/main/test/custom/client/utils.ts b/packages/openapi-ts-tests/main/test/custom/client/utils.ts index 92d66475d..475831637 100644 --- a/packages/openapi-ts-tests/main/test/custom/client/utils.ts +++ b/packages/openapi-ts-tests/main/test/custom/client/utils.ts @@ -334,48 +334,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: Interceptor[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + this.fns = []; } - clear() { - this._fns = []; + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; + } + } + + exists(id: number | Interceptor): boolean { + const index = this.getInterceptorIndex(id); + return Boolean(this.fns[index]); } - exists(fn: Interceptor) { - return this._fns.indexOf(fn) !== -1; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; + } + return this.fns.indexOf(id); } - eject(fn: Interceptor) { - const index = this._fns.indexOf(fn); - if (index !== -1) { - this._fns = [...this._fns.slice(0, index), ...this._fns.slice(index + 1)]; + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = fn; + return id; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts index c7ba67191..fd34020b6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts @@ -129,7 +129,7 @@ export const createClient = (config: Config = {}): Client => { let req = initialReq; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { req = await fn(req, opts as any); } @@ -150,7 +150,7 @@ export const createClient = (config: Config = {}): Client => { .pipe(filter((event) => event.type === HttpEventType.Response)), )) as HttpResponse; - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { result.response = await fn(result.response, req, opts as any); } @@ -176,7 +176,7 @@ export const createClient = (config: Config = {}): Client => { let finalError = error instanceof HttpErrorResponse ? error.error : error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn( finalError, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts index 65b0bc366..035208665 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts @@ -338,67 +338,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index 7165a5f01..b4932899a 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -84,7 +84,7 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, requestInit); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; let response = await _fetch(request); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, request, opts); } @@ -190,7 +190,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, request, opts)) as string; } @@ -225,7 +225,7 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { request = await fn(request, opts); } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/utils.ts index 13173d97d..73e2f92e2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/utils.ts @@ -242,67 +242,61 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(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' - >; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Req, + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index ca1a8e320..e3fb833f8 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -77,7 +77,7 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const { opts, url } = await beforeRequest(options); - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(opts); } @@ -93,7 +93,7 @@ export const createClient = (config: Config = {}): Client => { let response = await _fetch(url, requestInit); - for (const fn of interceptors.response._fns) { + for (const fn of interceptors.response.fns) { if (fn) { response = await fn(response, opts); } @@ -181,7 +181,7 @@ export const createClient = (config: Config = {}): Client => { const error = jsonError ?? textError; let finalError = error; - for (const fn of interceptors.error._fns) { + for (const fn of interceptors.error.fns) { if (fn) { finalError = (await fn(error, response, opts)) as string; } @@ -218,7 +218,7 @@ export const createClient = (config: Config = {}): Client => { method: init.method as Config['method'], url, }; - for (const fn of interceptors.request._fns) { + for (const fn of interceptors.request.fns) { if (fn) { await fn(requestInit); request = new Request(requestInit.url, requestInit); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/utils.ts index dfd3a19ab..5af8353a1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/utils.ts @@ -349,61 +349,60 @@ type ResInterceptor = ( ) => Res | Promise; class Interceptors { - _fns: (Interceptor | null)[]; + fns: Array = []; - constructor() { - this._fns = []; + clear(): void { + 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); + eject(id: number | Interceptor): void { + const index = this.getInterceptorIndex(id); + if (this.fns[index]) { + this.fns[index] = null; } } - exists(id: number | Interceptor) { + + exists(id: number | Interceptor): boolean { const index = this.getInterceptorIndex(id); - return !!this._fns[index]; + return Boolean(this.fns[index]); } - eject(id: number | Interceptor) { - const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = null; + getInterceptorIndex(id: number | Interceptor): number { + if (typeof id === 'number') { + return this.fns[id] ? id : -1; } + return this.fns.indexOf(id); } - update(id: number | Interceptor, fn: Interceptor) { + update( + id: number | Interceptor, + fn: Interceptor, + ): number | Interceptor | false { const index = this.getInterceptorIndex(id); - if (this._fns[index]) { - this._fns[index] = fn; + if (this.fns[index]) { + this.fns[index] = fn; return id; - } else { - return false; } + return false; } - use(fn: Interceptor) { - this._fns = [...this._fns, fn]; - return this._fns.length - 1; + use(fn: Interceptor): number { + this.fns.push(fn); + return this.fns.length - 1; } } -// `createInterceptors()` response, meant for external use as it does not -// expose internals export interface Middleware { - error: Pick>, 'eject' | 'use'>; - request: Pick>, 'eject' | 'use'>; - response: Pick>, 'eject' | 'use'>; + error: Interceptors>; + request: Interceptors>; + response: Interceptors>; } -// do not add `Middleware` as return type so we can use _fns internally -export const createInterceptors = () => ({ +export const createInterceptors = (): Middleware< + Res, + Err, + Options +> => ({ error: new Interceptors>(), request: new Interceptors>(), response: new Interceptors>(), -- 2.51.2 From 5a74da055e835b5160cb11e3d2be6921feeb18ad Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 22:13:40 +0800 Subject: [PATCH 07/19] chore: add changeset --- .changeset/many-ravens-wave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/many-ravens-wave.md diff --git a/.changeset/many-ravens-wave.md b/.changeset/many-ravens-wave.md new file mode 100644 index 000000000..c6e285b5d --- /dev/null +++ b/.changeset/many-ravens-wave.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(client): expose all interceptor methods -- 2.51.2 From 444a49a3f0855575c3ef1a3350fd102d42553f3e Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 22:54:53 +0800 Subject: [PATCH 08/19] feat(typescript): add topType option allowing to choose any over unknown --- .changeset/happy-kangaroos-shake.md | 5 ++++ .../openapi-ts-tests/main/test/3.1.x.test.ts | 15 +++++++++++- .../additional-properties-true-any/index.ts | 3 +++ .../types.gen.ts | 23 +++++++++++++++++++ .../main/test/openapi-ts.config.ts | 1 + .../src/plugins/@hey-api/typescript/config.ts | 1 + .../src/plugins/@hey-api/typescript/plugin.ts | 8 +++---- .../plugins/@hey-api/typescript/types.d.ts | 16 +++++++++++++ 8 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 .changeset/happy-kangaroos-shake.md create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts diff --git a/.changeset/happy-kangaroos-shake.md b/.changeset/happy-kangaroos-shake.md new file mode 100644 index 000000000..0901f0a32 --- /dev/null +++ b/.changeset/happy-kangaroos-shake.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +feat(typescript): add `topType` option allowing to choose `any` over `unknown` diff --git a/packages/openapi-ts-tests/main/test/3.1.x.test.ts b/packages/openapi-ts-tests/main/test/3.1.x.test.ts index b9c467e48..caef2c08b 100644 --- a/packages/openapi-ts-tests/main/test/3.1.x.test.ts +++ b/packages/openapi-ts-tests/main/test/3.1.x.test.ts @@ -70,7 +70,20 @@ describe(`OpenAPI ${version}`, () => { input: 'additional-properties-true.json', output: 'additional-properties-true', }), - description: 'allows arbitrary properties on objects', + description: 'allows arbitrary properties on objects (unknown top type)', + }, + { + config: createConfig({ + input: 'additional-properties-true.json', + output: 'additional-properties-true-any', + plugins: [ + { + name: '@hey-api/typescript', + topType: 'any', + }, + ], + }), + description: 'allows arbitrary properties on objects (any top type)', }, { config: createConfig({ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts new file mode 100644 index 000000000..0339b6e31 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts new file mode 100644 index 000000000..31ed4dfc7 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts @@ -0,0 +1,23 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo: string; + [key: string]: any | string; +}; + +export type Bar = Foo & { + [key: string]: any; +}; + +export type Baz = Foo & { + bar: string; + [key: string]: any | string; +}; + +export type Qux = { + [key: string]: any; +}; + +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 95aa64e58..c91c84a04 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -169,6 +169,7 @@ export default defineConfig(() => { // name: '我_responses_{{name}}', // response: '他_response_{{name}}', // }, + topType: 'any', // tree: true, // webhooks: { // name: 'Webby{{name}}Hook', 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 1ce3c1908..b812d7857 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts @@ -12,6 +12,7 @@ export const defaultConfig: HeyApiTypeScriptPlugin['Config'] = { case: 'PascalCase', exportFromIndex: true, style: 'preserve', + topType: 'unknown', tree: false, }, handler, 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 da8e5997c..1a930de77 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts @@ -39,9 +39,7 @@ const arrayTypeToIdentifier = ({ }): ts.TypeNode => { if (!schema.items) { return tsc.typeArrayNode( - tsc.keywordTypeNode({ - keyword: 'unknown', - }), + tsc.keywordTypeNode({ keyword: plugin.config.topType }), ); } @@ -332,7 +330,7 @@ const tupleTypeToIdentifier = ({ if (schema.const && Array.isArray(schema.const)) { itemTypes = schema.const.map((value) => { const expression = tsc.valueToExpression({ value }); - return expression ?? tsc.identifier({ text: 'unknown' }); + return expression ?? tsc.identifier({ text: plugin.config.topType }); }); } else if (schema.items) { for (const item of schema.items) { @@ -432,7 +430,7 @@ const schemaTypeToIdentifier = ({ }); case 'unknown': return tsc.keywordTypeNode({ - keyword: 'unknown', + keyword: plugin.config.topType, }); case 'void': return tsc.keywordTypeNode({ 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 965697341..d376378f2 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 @@ -199,6 +199,16 @@ export type UserConfig = Plugin.Name<'@hey-api/typescript'> & { */ response?: StringName; }; + /** + * The top type to use for untyped or unspecified schema values. + * + * Can be: + * - `unknown` (default): safe top type, you must narrow before use + * - `any`: disables type checking, can be used anywhere + * + * @default 'unknown' + */ + topType?: 'any' | 'unknown'; /** * Configuration for webhook-specific types. * @@ -429,6 +439,12 @@ export type Config = Plugin.Name<'@hey-api/typescript'> & { */ response: StringName; }; + /** + * The top type to use for untyped or unspecified schema values. + * + * @default 'unknown' + */ + topType: 'any' | 'unknown'; /** * Configuration for webhook-specific types. * -- 2.51.2 From 43a06617448344448375e0c13a156cb91666f3e9 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 23:42:26 +0800 Subject: [PATCH 09/19] fix(typescript): handle string and binary string in composite keywords --- .changeset/purple-elephants-lie.md | 5 ++ .../openapi-ts-tests/main/test/3.1.x.test.ts | 8 +++ .../3.1.x/pattern-properties/types.gen.ts | 2 +- .../3.1.x/string-with-format/index.ts | 3 + .../3.1.x/string-with-format/types.gen.ts | 9 +++ .../3.1.x/string-with-format/valibot.gen.ts | 7 ++ .../3.1.x/string-with-format/zod.gen.ts | 10 +++ .../test/generated/v2/types.gen.ts.snap | 26 ++++---- .../test/generated/v3/types.gen.ts.snap | 64 +++++++++---------- .../generated/v3_angular/types.gen.ts.snap | 64 +++++++++---------- .../v3_angular_transform/types.gen.ts.snap | 6 +- .../types.gen.ts.snap | 64 +++++++++---------- .../types.gen.ts.snap | 6 +- .../test/generated/v3_axios/types.gen.ts.snap | 64 +++++++++---------- .../v3_axios_transform/types.gen.ts.snap | 6 +- .../generated/v3_client/types.gen.ts.snap | 64 +++++++++---------- .../v3_client_transform/types.gen.ts.snap | 6 +- .../test/generated/v3_date/types.gen.ts.snap | 42 ++++++------ .../v3_enums_typescript/types.gen.ts.snap | 64 +++++++++---------- .../test/generated/v3_node/types.gen.ts.snap | 64 +++++++++---------- .../v3_node_transform/types.gen.ts.snap | 6 +- .../v3_services_filter/types.gen.ts.snap | 42 ++++++------ .../v3_services_name/types.gen.ts.snap | 42 ++++++------ .../generated/v3_transform/types.gen.ts.snap | 6 +- .../v3_tree_shakeable/types.gen.ts.snap | 64 +++++++++---------- .../test/generated/v3_xhr/types.gen.ts.snap | 64 +++++++++---------- .../v3_xhr_transform/types.gen.ts.snap | 6 +- .../main/test/openapi-ts.config.ts | 17 ++--- .../specs/3.1.x/string-with-format.yaml | 15 +++++ .../plugins/@hey-api/typescript/operation.ts | 3 +- .../src/plugins/@hey-api/typescript/plugin.ts | 2 +- packages/openapi-ts/src/tsc/typedef.ts | 30 +++++++-- 32 files changed, 478 insertions(+), 403 deletions(-) create mode 100644 .changeset/purple-elephants-lie.md create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/valibot.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/zod.gen.ts create mode 100644 packages/openapi-ts-tests/specs/3.1.x/string-with-format.yaml diff --git a/.changeset/purple-elephants-lie.md b/.changeset/purple-elephants-lie.md new file mode 100644 index 000000000..fe97933f6 --- /dev/null +++ b/.changeset/purple-elephants-lie.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(typescript): handle string and binary string in composite keywords diff --git a/packages/openapi-ts-tests/main/test/3.1.x.test.ts b/packages/openapi-ts-tests/main/test/3.1.x.test.ts index caef2c08b..8907d7ffe 100644 --- a/packages/openapi-ts-tests/main/test/3.1.x.test.ts +++ b/packages/openapi-ts-tests/main/test/3.1.x.test.ts @@ -941,6 +941,14 @@ describe(`OpenAPI ${version}`, () => { }), description: 'webhook types and validator schemas', }, + { + config: createConfig({ + input: 'string-with-format.yaml', + output: 'string-with-format', + plugins: ['@hey-api/typescript', 'valibot', 'zod'], + }), + description: 'anyOf string and binary string', + }, ]; it.each(scenarios)('$description', async ({ config }) => { 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 2557e4d7d..a99c8e749 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 @@ -27,7 +27,7 @@ export type UnionPatternObject = { [key: string]: unknown; } & { level?: number; - }) | (string | number) | ('user' | 'admin' | 'guest') | undefined; + }) | string | number | 'user' | 'admin' | 'guest' | undefined; }; export type PatternPropertiesResponse = { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts new file mode 100644 index 000000000..0339b6e31 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts @@ -0,0 +1,3 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts new file mode 100644 index 000000000..521723fb3 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts @@ -0,0 +1,9 @@ +// This file is auto-generated by @hey-api/openapi-ts + +export type Foo = { + foo?: Array; +}; + +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/valibot.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/valibot.gen.ts new file mode 100644 index 000000000..0d8332ad2 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/valibot.gen.ts @@ -0,0 +1,7 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import * as v from 'valibot'; + +export const vFoo = v.object({ + foo: v.optional(v.array(v.unknown())) +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/zod.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/zod.gen.ts new file mode 100644 index 000000000..ab38771c1 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/zod.gen.ts @@ -0,0 +1,10 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +export const zFoo = z.object({ + foo: z.optional(z.array(z.union([ + z.string(), + z.string() + ]))) +}); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v2/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v2/types.gen.ts.snap index 74e5af989..c43487e68 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v2/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v2/types.gen.ts.snap @@ -12,12 +12,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -35,7 +35,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing backticks in string: `backticks` and ```multiple backticks``` should work @@ -92,7 +92,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -117,7 +117,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -218,8 +218,8 @@ export type ModelThatExtendsExtends = ModelWithString & ModelThatExtends & { */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -244,7 +244,7 @@ export type ModelWithCircularReference = { */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -330,13 +330,13 @@ export type ModelWithInteger = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; }; /** @@ -461,7 +461,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3/types.gen.ts.snap index 58c1ec351..27c4b1682 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3/types.gen.ts.snap @@ -23,7 +23,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -72,12 +72,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -95,7 +95,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -252,7 +252,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -261,7 +261,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -315,7 +315,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -332,7 +332,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -346,7 +346,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -581,8 +581,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -590,8 +590,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -664,7 +664,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -759,7 +759,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -791,13 +791,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -1021,7 +1021,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1079,7 +1079,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1105,23 +1105,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type ComplexTypesData = { @@ -1151,7 +1151,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; @@ -1313,7 +1313,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type PostApiFormDataData = { /** @@ -1330,13 +1330,13 @@ export type CallWithResultFromHeaderResponse = (string); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1498,7 +1498,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1543,7 +1543,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap index eefd3fc21..03c4f2e7b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular/types.gen.ts.snap @@ -18,7 +18,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -67,12 +67,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -90,7 +90,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -247,7 +247,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -256,7 +256,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -310,7 +310,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -327,7 +327,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -341,7 +341,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -511,8 +511,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -520,8 +520,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -594,7 +594,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -689,7 +689,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -711,13 +711,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -941,7 +941,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -999,7 +999,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1025,23 +1025,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type ComplexTypesData = { @@ -1071,7 +1071,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; @@ -1233,7 +1233,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type PostApiFormDataData = { /** @@ -1250,13 +1250,13 @@ export type CallWithResultFromHeaderResponse = (string); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1418,7 +1418,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1463,7 +1463,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap index 8c9227850..5de1d89cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_transform/types.gen.ts.snap @@ -22,8 +22,8 @@ export type ParentModelWithDates = { 'nullable-date'?: Array<(Date | null)>; simpleItems?: Array; simpleItem?: SimpleModel; - dates?: Array<(Date)>; - strings?: Array<(string)>; + dates?: Array; + strings?: Array; }; /** @@ -41,7 +41,7 @@ export type ModelWithDatesResponse = (ModelWithDates); export type ModelWithDatesArrayResponse = (Array); -export type ArrayOfDatesResponse = (Array<(Date)>); +export type ArrayOfDatesResponse = (Array); export type DateResponse = (Date); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable/types.gen.ts.snap index 36ccc5819..eb2a891d6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable/types.gen.ts.snap @@ -18,7 +18,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -67,12 +67,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -90,7 +90,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -247,7 +247,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -256,7 +256,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -310,7 +310,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -327,7 +327,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -341,7 +341,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -511,8 +511,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -520,8 +520,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -594,7 +594,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -689,7 +689,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -711,13 +711,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -941,7 +941,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -999,7 +999,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1308,23 +1308,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type TypesData = { @@ -1335,7 +1335,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1380,7 +1380,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); @@ -1389,7 +1389,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type ComplexTypesData = { /** @@ -1412,13 +1412,13 @@ export type ComplexTypesResponse = (Array); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1433,7 +1433,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/types.gen.ts.snap index 8c9227850..5de1d89cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_angular_tree_shakeable_transform/types.gen.ts.snap @@ -22,8 +22,8 @@ export type ParentModelWithDates = { 'nullable-date'?: Array<(Date | null)>; simpleItems?: Array; simpleItem?: SimpleModel; - dates?: Array<(Date)>; - strings?: Array<(string)>; + dates?: Array; + strings?: Array; }; /** @@ -41,7 +41,7 @@ export type ModelWithDatesResponse = (ModelWithDates); export type ModelWithDatesArrayResponse = (Array); -export type ArrayOfDatesResponse = (Array<(Date)>); +export type ArrayOfDatesResponse = (Array); export type DateResponse = (Date); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap index 58c1ec351..27c4b1682 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios/types.gen.ts.snap @@ -23,7 +23,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -72,12 +72,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -95,7 +95,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -252,7 +252,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -261,7 +261,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -315,7 +315,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -332,7 +332,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -346,7 +346,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -581,8 +581,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -590,8 +590,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -664,7 +664,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -759,7 +759,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -791,13 +791,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -1021,7 +1021,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1079,7 +1079,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1105,23 +1105,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type ComplexTypesData = { @@ -1151,7 +1151,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; @@ -1313,7 +1313,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type PostApiFormDataData = { /** @@ -1330,13 +1330,13 @@ export type CallWithResultFromHeaderResponse = (string); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1498,7 +1498,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1543,7 +1543,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap index 8c9227850..5de1d89cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_axios_transform/types.gen.ts.snap @@ -22,8 +22,8 @@ export type ParentModelWithDates = { 'nullable-date'?: Array<(Date | null)>; simpleItems?: Array; simpleItem?: SimpleModel; - dates?: Array<(Date)>; - strings?: Array<(string)>; + dates?: Array; + strings?: Array; }; /** @@ -41,7 +41,7 @@ export type ModelWithDatesResponse = (ModelWithDates); export type ModelWithDatesArrayResponse = (Array); -export type ArrayOfDatesResponse = (Array<(Date)>); +export type ArrayOfDatesResponse = (Array); export type DateResponse = (Date); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap index 6f6821a65..21ee5921d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client/types.gen.ts.snap @@ -18,7 +18,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -67,12 +67,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -90,7 +90,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -247,7 +247,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -256,7 +256,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -310,7 +310,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -327,7 +327,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -341,7 +341,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -511,8 +511,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -520,8 +520,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -594,7 +594,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -689,7 +689,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -711,13 +711,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -941,7 +941,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -999,7 +999,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1025,23 +1025,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type ComplexTypesData = { @@ -1071,7 +1071,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; @@ -1233,7 +1233,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type PostApiFormDataData = { /** @@ -1250,13 +1250,13 @@ export type CallWithResultFromHeaderResponse = (string); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1418,7 +1418,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1463,7 +1463,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap index 8c9227850..5de1d89cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_client_transform/types.gen.ts.snap @@ -22,8 +22,8 @@ export type ParentModelWithDates = { 'nullable-date'?: Array<(Date | null)>; simpleItems?: Array; simpleItem?: SimpleModel; - dates?: Array<(Date)>; - strings?: Array<(string)>; + dates?: Array; + strings?: Array; }; /** @@ -41,7 +41,7 @@ export type ModelWithDatesResponse = (ModelWithDates); export type ModelWithDatesArrayResponse = (Array); -export type ArrayOfDatesResponse = (Array<(Date)>); +export type ArrayOfDatesResponse = (Array); export type DateResponse = (Date); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap index 3cc9be046..0913515f8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_date/types.gen.ts.snap @@ -18,7 +18,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -67,12 +67,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -90,7 +90,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -247,7 +247,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -256,7 +256,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -310,7 +310,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -327,7 +327,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -341,7 +341,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -511,8 +511,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -520,8 +520,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -594,7 +594,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -689,7 +689,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -711,13 +711,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -941,7 +941,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -999,7 +999,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap index 77f604255..ef85bc585 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_enums_typescript/types.gen.ts.snap @@ -21,7 +21,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -70,12 +70,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -93,7 +93,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -250,7 +250,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -259,7 +259,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -313,7 +313,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -330,7 +330,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -344,7 +344,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -560,8 +560,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -569,8 +569,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -643,7 +643,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -738,7 +738,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -766,13 +766,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -996,7 +996,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1054,7 +1054,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1080,23 +1080,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type ComplexTypesData = { @@ -1126,7 +1126,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; @@ -1288,7 +1288,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type PostApiFormDataData = { /** @@ -1305,13 +1305,13 @@ export type CallWithResultFromHeaderResponse = (string); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1473,7 +1473,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1518,7 +1518,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap index 58c1ec351..27c4b1682 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node/types.gen.ts.snap @@ -23,7 +23,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -72,12 +72,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -95,7 +95,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -252,7 +252,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -261,7 +261,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -315,7 +315,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -332,7 +332,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -346,7 +346,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -581,8 +581,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -590,8 +590,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -664,7 +664,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -759,7 +759,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -791,13 +791,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -1021,7 +1021,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1079,7 +1079,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1105,23 +1105,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type ComplexTypesData = { @@ -1151,7 +1151,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; @@ -1313,7 +1313,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type PostApiFormDataData = { /** @@ -1330,13 +1330,13 @@ export type CallWithResultFromHeaderResponse = (string); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1498,7 +1498,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1543,7 +1543,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap index 8c9227850..5de1d89cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_node_transform/types.gen.ts.snap @@ -22,8 +22,8 @@ export type ParentModelWithDates = { 'nullable-date'?: Array<(Date | null)>; simpleItems?: Array; simpleItem?: SimpleModel; - dates?: Array<(Date)>; - strings?: Array<(string)>; + dates?: Array; + strings?: Array; }; /** @@ -41,7 +41,7 @@ export type ModelWithDatesResponse = (ModelWithDates); export type ModelWithDatesArrayResponse = (Array); -export type ArrayOfDatesResponse = (Array<(Date)>); +export type ArrayOfDatesResponse = (Array); export type DateResponse = (Date); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_filter/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_filter/types.gen.ts.snap index f17da153b..54c9b51ce 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_filter/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_filter/types.gen.ts.snap @@ -23,7 +23,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -72,12 +72,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -95,7 +95,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -252,7 +252,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -261,7 +261,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -315,7 +315,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -332,7 +332,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -346,7 +346,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -581,8 +581,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -590,8 +590,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -664,7 +664,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -759,7 +759,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -791,13 +791,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -1021,7 +1021,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1079,7 +1079,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_name/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_name/types.gen.ts.snap index 5d94e5185..9fb1e5b11 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_name/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_services_name/types.gen.ts.snap @@ -23,7 +23,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -72,12 +72,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -95,7 +95,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -252,7 +252,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -261,7 +261,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -315,7 +315,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -332,7 +332,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -346,7 +346,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -581,8 +581,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -590,8 +590,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -664,7 +664,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -759,7 +759,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -791,13 +791,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -1021,7 +1021,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1079,7 +1079,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap index 8c9227850..5de1d89cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_transform/types.gen.ts.snap @@ -22,8 +22,8 @@ export type ParentModelWithDates = { 'nullable-date'?: Array<(Date | null)>; simpleItems?: Array; simpleItem?: SimpleModel; - dates?: Array<(Date)>; - strings?: Array<(string)>; + dates?: Array; + strings?: Array; }; /** @@ -41,7 +41,7 @@ export type ModelWithDatesResponse = (ModelWithDates); export type ModelWithDatesArrayResponse = (Array); -export type ArrayOfDatesResponse = (Array<(Date)>); +export type ArrayOfDatesResponse = (Array); export type DateResponse = (Date); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap index a6a6dbeb6..ecb4fde89 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_tree_shakeable/types.gen.ts.snap @@ -23,7 +23,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -72,12 +72,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -95,7 +95,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -252,7 +252,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -261,7 +261,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -315,7 +315,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -332,7 +332,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -346,7 +346,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -581,8 +581,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -590,8 +590,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -664,7 +664,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -759,7 +759,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -791,13 +791,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -1021,7 +1021,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1079,7 +1079,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1388,23 +1388,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type TypesData = { @@ -1415,7 +1415,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1460,7 +1460,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); @@ -1469,7 +1469,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type ComplexTypesData = { /** @@ -1492,13 +1492,13 @@ export type ComplexTypesResponse = (Array); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1513,7 +1513,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap index 58c1ec351..27c4b1682 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr/types.gen.ts.snap @@ -23,7 +23,7 @@ export type _import = string; export type AdditionalPropertiesIntegerIssue = { value: number; - [key: string]: (number) | undefined; + [key: string]: number | undefined; }; export type AdditionalPropertiesUnknownIssue = { @@ -72,12 +72,12 @@ export type ArrayWithArray = Array>; /** * This is a simple array with booleans */ -export type ArrayWithBooleans = Array<(boolean)>; +export type ArrayWithBooleans = Array; /** * This is a simple array with numbers */ -export type ArrayWithNumbers = Array<(number)>; +export type ArrayWithNumbers = Array; /** * This is a simple array with properties @@ -95,7 +95,7 @@ export type ArrayWithReferences = Array; /** * This is a simple array with strings */ -export type ArrayWithStrings = Array<(string)>; +export type ArrayWithStrings = Array; /** * Testing multiline comments in string: First line @@ -252,7 +252,7 @@ export type CompositionWithOneOfAndProperties = ({ */ export type CompositionWithOneOfAndSimpleArrayDictionary = { propA?: (boolean | { - [key: string]: Array<(boolean)>; + [key: string]: Array; }); }; @@ -261,7 +261,7 @@ export type CompositionWithOneOfAndSimpleArrayDictionary = { */ export type CompositionWithOneOfAndSimpleDictionary = { propA?: (boolean | { - [key: string]: (number); + [key: string]: number; }); }; @@ -315,7 +315,7 @@ export type DictionaryWithArray = { */ export type DictionaryWithDictionary = { [key: string]: { - [key: string]: (string); + [key: string]: string; }; }; @@ -332,7 +332,7 @@ export type DictionaryWithProperties = { export type DictionaryWithPropertiesAndAdditionalProperties = { foo?: number; bar?: boolean; - [key: string]: (string | number | boolean) | undefined; + [key: string]: string | number | boolean | undefined; }; /** @@ -346,7 +346,7 @@ export type DictionaryWithReference = { * This is a string dictionary */ export type DictionaryWithString = { - [key: string]: (string); + [key: string]: string; }; /** @@ -581,8 +581,8 @@ export type ModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = [ */ export type ModelWithArray = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -590,8 +590,8 @@ export type ModelWithArray = { */ export type ModelWithArrayReadOnlyAndWriteOnly = { prop?: Array; - propWithFile?: Array<((Blob | File))>; - propWithNumber?: Array<(number)>; + propWithFile?: Array; + propWithNumber?: Array; }; /** @@ -664,7 +664,7 @@ export type ModelWithConstantSizeArray = [ */ export type ModelWithDictionary = { prop?: { - [key: string]: (string); + [key: string]: string; }; }; @@ -759,7 +759,7 @@ export type ModelWithInteger = { }; export type ModelWithNestedArrayEnums = { - array_strings?: Array<(string)>; + array_strings?: Array; data?: (ModelWithNestedArrayEnumsData); }; @@ -791,13 +791,13 @@ export type ModelWithNestedCompositionEnums = { */ export type ModelWithNestedEnums = { dictionaryWithEnum?: { - [key: string]: ('Success' | 'Warning' | 'Error'); + [key: string]: 'Success' | 'Warning' | 'Error'; }; dictionaryWithEnumFromDescription?: { - [key: string]: (number); + [key: string]: number; }; - arrayWithEnum?: Array<('Success' | 'Warning' | 'Error')>; - arrayWithDescription?: Array<(number)>; + arrayWithEnum?: Array<'Success' | 'Warning' | 'Error'>; + arrayWithDescription?: Array; /** * This is a simple enum with strings */ @@ -1021,7 +1021,7 @@ export type OneOfAllOfIssue = ((ConstValue | Generic_Schema_Duplicate_Issue_1_Sy export type Pageable = { page?: number; size?: number; - sort?: Array<(string)>; + sort?: Array; }; /** @@ -1079,7 +1079,7 @@ export type SimpleBoolean = boolean; /** * This is a simple file */ -export type SimpleFile = (Blob | File); +export type SimpleFile = Blob | File; /** * This is a simple number @@ -1105,23 +1105,23 @@ export type CollectionFormatData = { /** * This is an array parameter that is sent as csv format (comma-separated values) */ - parameterArrayCsv: Array<(string)> | null; + parameterArrayCsv: Array | null; /** * This is an array parameter that is sent as multi format (multiple parameter instances) */ - parameterArrayMulti: Array<(string)> | null; + parameterArrayMulti: Array | null; /** * This is an array parameter that is sent as pipes format (pipe-separated values) */ - parameterArrayPipes: Array<(string)> | null; + parameterArrayPipes: Array | null; /** * This is an array parameter that is sent as ssv format (space-separated values) */ - parameterArraySsv: Array<(string)> | null; + parameterArraySsv: Array | null; /** * This is an array parameter that is sent as tsv format (tab-separated values) */ - parameterArrayTsv: Array<(string)> | null; + parameterArrayTsv: Array | null; }; export type ComplexTypesData = { @@ -1151,7 +1151,7 @@ export type ComplexParamsData = { enabled?: boolean; readonly type: 'Monkey' | 'Horse' | 'Bird'; listOfModels?: Array | null; - listOfStrings?: Array<(string)> | null; + listOfStrings?: Array | null; parameters: (ModelWithString | ModelWithEnum | ModelWithArray | ModelWithDictionary); readonly user?: { readonly id?: number; @@ -1313,7 +1313,7 @@ export type FileResponseData = { id: string; }; -export type FileResponseResponse = ((Blob | File)); +export type FileResponseResponse = (Blob | File); export type PostApiFormDataData = { /** @@ -1330,13 +1330,13 @@ export type CallWithResultFromHeaderResponse = (string); export type MultipartRequestData = { formData?: { - content?: (Blob | File); + content?: Blob | File; data?: ((ModelWithString) | null); }; }; export type MultipartResponseResponse = ({ - file?: (Blob | File); + file?: Blob | File; metadata?: { foo?: string; bar?: string; @@ -1498,7 +1498,7 @@ export type TypesData = { /** * This is an array parameter */ - parameterArray: Array<(string)> | null; + parameterArray: Array | null; /** * This is a boolean parameter */ @@ -1543,7 +1543,7 @@ export type TypesResponse = (number | string | boolean | { }); export type UploadFileData = { - formData: (Blob | File); + formData: Blob | File; }; export type UploadFileResponse = (boolean); \ No newline at end of file diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap index 8c9227850..5de1d89cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_xhr_transform/types.gen.ts.snap @@ -22,8 +22,8 @@ export type ParentModelWithDates = { 'nullable-date'?: Array<(Date | null)>; simpleItems?: Array; simpleItem?: SimpleModel; - dates?: Array<(Date)>; - strings?: Array<(string)>; + dates?: Array; + strings?: Array; }; /** @@ -41,7 +41,7 @@ export type ModelWithDatesResponse = (ModelWithDates); export type ModelWithDatesArrayResponse = (Array); -export type ArrayOfDatesResponse = (Array<(Date)>); +export type ArrayOfDatesResponse = (Array); export type DateResponse = (Date); 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 c91c84a04..dadb04614 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -36,9 +36,10 @@ export default defineConfig(() => { '3.1.x', // 'invalid', // 'openai.yaml', - 'full.yaml', + // 'full.yaml', // 'opencode.yaml', // 'sdk-instance.yaml', + 'string-with-format.yaml', // 'validators-circular-ref-2.yaml', // 'zoom-video-sdk.json', ), @@ -138,9 +139,9 @@ export default defineConfig(() => { validate_EXPERIMENTAL: true, }, plugins: [ - customClientPlugin({ - baseUrl: false, - }), + // customClientPlugin({ + // baseUrl: false, + // }), // myClientPlugin(), { // baseUrl: false, @@ -169,7 +170,7 @@ export default defineConfig(() => { // name: '我_responses_{{name}}', // response: '他_response_{{name}}', // }, - topType: 'any', + // topType: 'any', // tree: true, // webhooks: { // name: 'Webby{{name}}Hook', @@ -184,7 +185,7 @@ export default defineConfig(() => { // client: false, // include... // instance: true, - name: '@hey-api/sdk', + // name: '@hey-api/sdk', // operationId: false, // params: 'experiment', // responseStyle: 'data', @@ -217,7 +218,7 @@ export default defineConfig(() => { // mutationOptions: { // name: '{{name}}MO', // }, - name: '@tanstack/react-query', + // name: '@tanstack/react-query', // queryKeys: { // name: '{{name}}QK', // }, @@ -278,7 +279,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/specs/3.1.x/string-with-format.yaml b/packages/openapi-ts-tests/specs/3.1.x/string-with-format.yaml new file mode 100644 index 000000000..3c4bf61e1 --- /dev/null +++ b/packages/openapi-ts-tests/specs/3.1.x/string-with-format.yaml @@ -0,0 +1,15 @@ +openapi: 3.1.1 +info: + title: OpenAPI 3.1.1 string with format example + version: '1' +components: + schemas: + Foo: + properties: + foo: + items: + anyOf: + - type: string + format: binary + - type: string + type: array 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 743c12ae6..75c27d05f 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts @@ -6,8 +6,7 @@ import { tsc } from '../../../tsc'; import { schemaToType } from './plugin'; import type { HeyApiTypeScriptPlugin, PluginState } from './types'; -// TODO: exported just for @pinia/colada, remove export once that plugin does not depend on it -export const irParametersToIrSchema = ({ +const irParametersToIrSchema = ({ parameters, }: { parameters: Record; 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 1a930de77..256924466 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts @@ -43,7 +43,7 @@ const arrayTypeToIdentifier = ({ ); } - schema = deduplicateSchema({ detectFormat: false, schema }); + schema = deduplicateSchema({ detectFormat: true, schema }); const itemTypes: Array = []; diff --git a/packages/openapi-ts/src/tsc/typedef.ts b/packages/openapi-ts/src/tsc/typedef.ts index b7b661872..600e1179c 100644 --- a/packages/openapi-ts/src/tsc/typedef.ts +++ b/packages/openapi-ts/src/tsc/typedef.ts @@ -181,9 +181,18 @@ export const createTypeUnionNode = ({ isNullable?: boolean; types: ReadonlyArray; }) => { - const nodes = types.map((type) => createTypeNode(type)); - const node = ts.factory.createUnionTypeNode(nodes); - return maybeNullable({ isNullable, node }); + // flatten nested unions + const nodes: Array = []; + for (const type of types) { + const node = createTypeNode(type); + if (ts.isUnionTypeNode(node)) { + nodes.push(...node.types); + } else { + nodes.push(node); + } + } + const unionNode = ts.factory.createUnionTypeNode(nodes); + return maybeNullable({ isNullable, node: unionNode }); }; /** @@ -199,9 +208,18 @@ export const createTypeIntersectionNode = ({ isNullable?: boolean; types: (any | ts.TypeNode)[]; }) => { - const nodes = types.map((type) => createTypeNode(type)); - const node = ts.factory.createIntersectionTypeNode(nodes); - return maybeNullable({ isNullable, node }); + // flatten nested intersections + const nodes: Array = []; + for (const type of types) { + const node = createTypeNode(type); + if (ts.isIntersectionTypeNode(node)) { + nodes.push(...node.types); + } else { + nodes.push(node); + } + } + const intersectionNode = ts.factory.createIntersectionTypeNode(nodes); + return maybeNullable({ isNullable, node: intersectionNode }); }; /** -- 2.51.2 From 2b46632875e504edf268457e5b57e2e2cb091708 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 15:56:48 +0000 Subject: [PATCH 10/19] ci: release --- .changeset/happy-kangaroos-shake.md | 5 ----- .changeset/many-ravens-wave.md | 5 ----- .changeset/odd-fireants-lay.md | 5 ----- .changeset/purple-elephants-lie.md | 5 ----- packages/openapi-ts/CHANGELOG.md | 12 ++++++++++++ packages/openapi-ts/package.json | 2 +- 6 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 .changeset/happy-kangaroos-shake.md delete mode 100644 .changeset/many-ravens-wave.md delete mode 100644 .changeset/odd-fireants-lay.md delete mode 100644 .changeset/purple-elephants-lie.md diff --git a/.changeset/happy-kangaroos-shake.md b/.changeset/happy-kangaroos-shake.md deleted file mode 100644 index 0901f0a32..000000000 --- a/.changeset/happy-kangaroos-shake.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@hey-api/openapi-ts': patch ---- - -feat(typescript): add `topType` option allowing to choose `any` over `unknown` diff --git a/.changeset/many-ravens-wave.md b/.changeset/many-ravens-wave.md deleted file mode 100644 index c6e285b5d..000000000 --- a/.changeset/many-ravens-wave.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@hey-api/openapi-ts': patch ---- - -fix(client): expose all interceptor methods diff --git a/.changeset/odd-fireants-lay.md b/.changeset/odd-fireants-lay.md deleted file mode 100644 index 3fa74523f..000000000 --- a/.changeset/odd-fireants-lay.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@hey-api/openapi-ts': patch ---- - -fix(config): correctly load user-defined hooks diff --git a/.changeset/purple-elephants-lie.md b/.changeset/purple-elephants-lie.md deleted file mode 100644 index fe97933f6..000000000 --- a/.changeset/purple-elephants-lie.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@hey-api/openapi-ts': patch ---- - -fix(typescript): handle string and binary string in composite keywords diff --git a/packages/openapi-ts/CHANGELOG.md b/packages/openapi-ts/CHANGELOG.md index 149789736..c4aa21c90 100644 --- a/packages/openapi-ts/CHANGELOG.md +++ b/packages/openapi-ts/CHANGELOG.md @@ -1,5 +1,17 @@ # @hey-api/openapi-ts +## 0.83.1 + +### Patch Changes + +- feat(typescript): add `topType` option allowing to choose `any` over `unknown` ([#2629](https://github.com/hey-api/openapi-ts/pull/2629)) ([`444a49a`](https://github.com/hey-api/openapi-ts/commit/444a49a3f0855575c3ef1a3350fd102d42553f3e)) by [@mrlubos](https://github.com/mrlubos) + +- fix(client): expose all interceptor methods ([#2627](https://github.com/hey-api/openapi-ts/pull/2627)) ([`5a74da0`](https://github.com/hey-api/openapi-ts/commit/5a74da055e835b5160cb11e3d2be6921feeb18ad)) by [@mrlubos](https://github.com/mrlubos) + +- fix(config): correctly load user-defined hooks ([#2623](https://github.com/hey-api/openapi-ts/pull/2623)) ([`1193c4d`](https://github.com/hey-api/openapi-ts/commit/1193c4dce77e0cb02c32b25661f22065a18bd095)) by [@mrlubos](https://github.com/mrlubos) + +- fix(typescript): handle string and binary string in composite keywords ([#2630](https://github.com/hey-api/openapi-ts/pull/2630)) ([`43a0661`](https://github.com/hey-api/openapi-ts/commit/43a06617448344448375e0c13a156cb91666f3e9)) by [@mrlubos](https://github.com/mrlubos) + ## 0.83.0 ### Minor Changes diff --git a/packages/openapi-ts/package.json b/packages/openapi-ts/package.json index 0dba90302..ebbd30121 100644 --- a/packages/openapi-ts/package.json +++ b/packages/openapi-ts/package.json @@ -1,6 +1,6 @@ { "name": "@hey-api/openapi-ts", - "version": "0.83.0", + "version": "0.83.1", "description": "🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.", "homepage": "https://heyapi.dev/", "repository": { -- 2.51.2 From e5b3a1e8ab05712acfb1adb5e663c2f35c86dc6a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 13:30:03 +0000 Subject: [PATCH 11/19] Initial plan -- 2.51.2 From 7b02b8ae70f2bf760d85ecdeec007cb63582df8d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 13:38:17 +0000 Subject: [PATCH 12/19] Initial plan -- 2.51.2 From 29d24794ccb16e8a070608ec3698d919813267ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 13:49:35 +0000 Subject: [PATCH 13/19] Fix Zod schema union deduplication by including validation constraints in type ID Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../validators-string-constraints-union.json | 27 +++++++++++++++++++ .../zod.gen.ts | 8 ++++++ .../zod.gen.ts | 8 ++++++ .../zod.gen.ts | 8 ++++++ .../zod/v3/test/3.1.x.test.ts | 7 +++++ .../zod.gen.ts | 8 ++++++ .../zod.gen.ts | 8 ++++++ .../zod.gen.ts | 8 ++++++ .../zod/v4/test/3.1.x.test.ts | 7 +++++ packages/openapi-ts/src/ir/schema.ts | 20 +++++++++++++- 10 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 packages/openapi-ts-tests/specs/3.1.x/validators-string-constraints-union.json create mode 100644 packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts diff --git a/packages/openapi-ts-tests/specs/3.1.x/validators-string-constraints-union.json b/packages/openapi-ts-tests/specs/3.1.x/validators-string-constraints-union.json new file mode 100644 index 000000000..1f09f3783 --- /dev/null +++ b/packages/openapi-ts-tests/specs/3.1.x/validators-string-constraints-union.json @@ -0,0 +1,27 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "String Constraints Union Test", + "version": "1.0.0" + }, + "components": { + "schemas": { + "LocaleOrLanguage": { + "anyOf": [ + { + "type": "string", + "minLength": 5, + "maxLength": 5, + "description": "Combination of ISO 639-1 and ISO 3166-1 alpha-2 separated by a hyphen." + }, + { + "type": "string", + "minLength": 2, + "maxLength": 2, + "description": "ISO 639-1 language code." + } + ] + } + } + } +} diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts new file mode 100644 index 000000000..1e8242e45 --- /dev/null +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import * as z from 'zod/v4-mini'; + +export const zLocaleOrLanguage = z.union([ + z.string().check(z.length(5)), + z.string().check(z.length(2)) +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts new file mode 100644 index 000000000..5027df72f --- /dev/null +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +export const zLocaleOrLanguage = z.union([ + z.string().length(5), + z.string().length(2) +]); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts new file mode 100644 index 000000000..531f15719 --- /dev/null +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod/v4'; + +export const zLocaleOrLanguage = z.union([ + z.string().length(5), + z.string().length(2) +]); diff --git a/packages/openapi-ts-tests/zod/v3/test/3.1.x.test.ts b/packages/openapi-ts-tests/zod/v3/test/3.1.x.test.ts index 8ec15f08d..4fedd7c55 100644 --- a/packages/openapi-ts-tests/zod/v3/test/3.1.x.test.ts +++ b/packages/openapi-ts-tests/zod/v3/test/3.1.x.test.ts @@ -138,6 +138,13 @@ for (const zodVersion of zodVersions) { description: "validator schemas with merged unions (can't use .merge())", }, + { + config: createConfig({ + input: 'validators-string-constraints-union.json', + output: 'validators-string-constraints-union', + }), + description: 'validator schemas with string constraints union', + }, ]; it.each(scenarios)('$description', async ({ config }) => { diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts new file mode 100644 index 000000000..99addfb0b --- /dev/null +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-string-constraints-union/zod.gen.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import * as z from 'zod/mini'; + +export const zLocaleOrLanguage = z.union([ + z.string().check(z.length(5)), + z.string().check(z.length(2)) +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts new file mode 100644 index 000000000..6a9afba9d --- /dev/null +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-string-constraints-union/zod.gen.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod/v3'; + +export const zLocaleOrLanguage = z.union([ + z.string().length(5), + z.string().length(2) +]); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts new file mode 100644 index 000000000..5027df72f --- /dev/null +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-string-constraints-union/zod.gen.ts @@ -0,0 +1,8 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +export const zLocaleOrLanguage = z.union([ + z.string().length(5), + z.string().length(2) +]); diff --git a/packages/openapi-ts-tests/zod/v4/test/3.1.x.test.ts b/packages/openapi-ts-tests/zod/v4/test/3.1.x.test.ts index 8ec15f08d..4fedd7c55 100644 --- a/packages/openapi-ts-tests/zod/v4/test/3.1.x.test.ts +++ b/packages/openapi-ts-tests/zod/v4/test/3.1.x.test.ts @@ -138,6 +138,13 @@ for (const zodVersion of zodVersions) { description: "validator schemas with merged unions (can't use .merge())", }, + { + config: createConfig({ + input: 'validators-string-constraints-union.json', + output: 'validators-string-constraints-union', + }), + description: 'validator schemas with string constraints union', + }, ]; it.each(scenarios)('$description', async ({ config }) => { diff --git a/packages/openapi-ts/src/ir/schema.ts b/packages/openapi-ts/src/ir/schema.ts index b9e42c669..b257a3a45 100644 --- a/packages/openapi-ts/src/ir/schema.ts +++ b/packages/openapi-ts/src/ir/schema.ts @@ -42,7 +42,25 @@ export const deduplicateSchema = ({ item.format !== undefined && detectFormat ? `format-${item.format}` : ''; - const typeId = `${item.$ref ?? ''}${item.type ?? ''}${constant}${format}`; + + // Include validation constraints in the type ID to avoid incorrect deduplication + const constraints = [ + item.minLength !== undefined ? `minLength-${item.minLength}` : '', + item.maxLength !== undefined ? `maxLength-${item.maxLength}` : '', + item.minimum !== undefined ? `minimum-${item.minimum}` : '', + item.maximum !== undefined ? `maximum-${item.maximum}` : '', + item.exclusiveMinimum !== undefined + ? `exclusiveMinimum-${item.exclusiveMinimum}` + : '', + item.exclusiveMaximum !== undefined + ? `exclusiveMaximum-${item.exclusiveMaximum}` + : '', + item.minItems !== undefined ? `minItems-${item.minItems}` : '', + item.maxItems !== undefined ? `maxItems-${item.maxItems}` : '', + item.pattern !== undefined ? `pattern-${item.pattern}` : '', + ].join(''); + + const typeId = `${item.$ref ?? ''}${item.type ?? ''}${constant}${format}${constraints}`; if (!typeIds.includes(typeId)) { typeIds.push(typeId); uniqueItems.push(item); -- 2.51.2 From e5373397e10990e1150b3a908ba1d8bba5cc73c1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 14:00:29 +0000 Subject: [PATCH 14/19] Add comprehensive GitHub Copilot instructions for hey-api/openapi-ts repository Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .github/copilot-instructions.md | 210 ++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..54a687598 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,210 @@ +# Hey API OpenAPI TypeScript Codegen + +OpenAPI TypeScript is a CLI tool and library for generating TypeScript clients, SDKs, validators, and schemas from OpenAPI specifications. This is a monorepo built with pnpm workspaces, Turbo build orchestration, and TypeScript. + +**ALWAYS reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.** + +## Working Effectively + +### Prerequisites and Setup + +- Install Node.js 20.19.0+ or 24.7.0+ (see `.nvmrc` for current version: 24.7.0) +- Install pnpm globally: `npm install -g pnpm@10.15.1` +- Clone the repository and run setup commands + +### Bootstrap, Build, and Test + +```bash +# Install dependencies (takes ~1m 20s) +pnpm install + +# Build packages only (NEVER CANCEL - takes ~2m 15s - set timeout to 180+ seconds) +pnpm build --filter="@hey-api/**" + +# Build all including examples (NEVER CANCEL - takes ~5+ minutes - set timeout to 360+ seconds) +pnpm build + +# Run tests (takes ~1m 5s - set timeout to 120+ seconds) +# NOTE: Some network-dependent tests may fail in sandboxed environments +pnpm test + +# Run linting (takes ~35s) +pnpm lint + +# Run type checking (NEVER CANCEL - takes ~1m 20s - set timeout to 120+ seconds) +pnpm typecheck + +# Format code (takes ~35s) +pnpm format +``` + +### Development Workflow + +```bash +# Start development mode for main package (watches for changes) +pnpm --filter @hey-api/openapi-ts dev + +# Start development server for examples (e.g., fetch example) +pnpm --filter @example/openapi-ts-fetch dev +# Server starts on http://localhost:5173/ + +# Run CLI tool directly +node packages/openapi-ts/bin/index.cjs --help +# or after building +npx @hey-api/openapi-ts --help +``` + +## Build and Test Details + +### **CRITICAL BUILD TIMING** + +- **NEVER CANCEL BUILD COMMANDS** - They may take 2-5+ minutes +- `pnpm build --filter="@hey-api/**"`: ~2m 15s (packages only) +- `pnpm build`: ~5+ minutes (includes docs and examples) +- `pnpm install`: ~1m 20s +- `pnpm test`: ~1m 5s +- `pnpm typecheck`: ~1m 20s +- `pnpm lint`: ~35s +- `pnpm format`: ~35s + +### Build Issues and Workarounds + +- **Docs build may fail** due to pnpm version mismatch in VitePress - this is expected in some environments +- Use `pnpm build --filter="@hey-api/**"` to build packages without docs +- **Some tests may fail** in sandboxed environments due to network restrictions (OpenAPI spec downloads) +- **Generated test files** in `packages/openapi-ts-tests/` contain auto-generated snapshots that may have linting warnings - this is expected +- **Linting issues** in `.gen/snapshots/` directories are expected for generated code + +## Validation + +### Manual Testing Scenarios + +After making changes, ALWAYS validate with these scenarios: + +1. **CLI Functionality Test**: + + ```bash + # Test CLI help + node packages/openapi-ts/bin/index.cjs --help + + # Test CLI version + node packages/openapi-ts/bin/index.cjs --version + + # Test basic code generation with a simple OpenAPI spec + # Create a minimal test spec and generate client code + node packages/openapi-ts/bin/index.cjs -i path/to/spec.json -o ./test-output --plugins "@hey-api/client-fetch" "@hey-api/typescript" + ``` + +2. **Example Application Test**: + + ```bash + # Start fetch example and verify it loads + pnpm --filter @example/openapi-ts-fetch dev + # Should start on http://localhost:5173/ + ``` + +3. **Development Mode Test**: + ```bash + # Start dev mode and make a small change to verify rebuilding + pnpm --filter @hey-api/openapi-ts dev + ``` + +### Pre-commit Validation + +ALWAYS run these commands before committing or the CI will fail: + +```bash +# Use lint:fix to auto-fix issues (some warnings in generated test files are expected) +pnpm lint:fix + +# Run typecheck (can target specific packages with --filter) +pnpm typecheck + +# Run tests (some network tests may fail in sandboxed environments) +pnpm test +``` + +**NOTE**: Some linting warnings in generated test snapshot files (`.gen/snapshots/`) are expected and should be ignored. The `lint:fix` command will resolve actual source code issues. + +## Repository Structure + +### Key Packages + +- `packages/openapi-ts/` - Main CLI tool and library +- `packages/codegen-core/` - Core code generation utilities +- `packages/custom-client/` - Custom HTTP client implementations +- `packages/nuxt/` - Nuxt.js integration +- `packages/vite-plugin/` - Vite plugin + +### Examples + +- `examples/openapi-ts-fetch/` - Fetch client example (React + Vite) +- `examples/openapi-ts-angular/` - Angular client example +- `examples/openapi-ts-tanstack-react-query/` - TanStack React Query integration +- `examples/openapi-ts-vue/` - Vue.js integration +- Plus many more framework-specific examples + +### Configuration Files + +- `pnpm-workspace.yaml` - Workspace configuration +- `turbo.json` - Turbo build configuration +- `package.json` - Root package with workspace scripts +- `.nvmrc` - Node.js version specification + +## Common Tasks + +### Working with the Main Package + +```bash +# Install deps for main package +pnpm --filter @hey-api/openapi-ts install + +# Build main package only +pnpm --filter @hey-api/openapi-ts build + +# Test main package only +pnpm --filter @hey-api/openapi-ts test + +# Start dev mode for main package +pnpm --filter @hey-api/openapi-ts dev +``` + +### Working with Examples + +```bash +# List all example packages +ls examples/ + +# Run specific example +pnpm --filter @example/openapi-ts-fetch dev + +# Build all examples +pnpm build --filter="@example/**" +``` + +### Debugging and Troubleshooting + +- Check `turbo.json` for task dependencies and configuration +- Use `pnpm list` to see installed packages +- Use `pnpm why ` to understand dependency chains +- Check individual package `package.json` files for available scripts + +## CI/CD Pipeline + +The repository uses GitHub Actions (`.github/workflows/ci.yml`): + +- Tests on multiple Node.js versions (20.19.0, 22.12.0, 24.7.0) +- Tests on multiple OS (macOS, Ubuntu, Windows) +- Runs build, lint, typecheck, and test commands +- Publishes preview packages on PRs + +## Performance Expectations + +- **Cold install**: ~1m 20s +- **Cold build**: ~2-5m depending on scope +- **Incremental builds**: ~30s in dev mode +- **Test suite**: ~1m 5s +- **Linting**: ~35s +- **Type checking**: ~1m 20s + +Remember: This is a complex monorepo with many dependencies. Be patient with build times and always use appropriate timeouts for long-running commands. -- 2.51.2 From 31b3933b2caa1085dbead1ef94695bca4b83d6ac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Sep 2025 14:35:59 +0000 Subject: [PATCH 15/19] Add changeset for Zod union deduplication fix Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .changeset/fix-zod-union-deduplication.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .changeset/fix-zod-union-deduplication.md diff --git a/.changeset/fix-zod-union-deduplication.md b/.changeset/fix-zod-union-deduplication.md new file mode 100644 index 000000000..64126f8d3 --- /dev/null +++ b/.changeset/fix-zod-union-deduplication.md @@ -0,0 +1,13 @@ +--- +"@hey-api/openapi-ts": patch +--- + +Fix Zod schema union deduplication by including validation constraints in type ID + +The Zod plugin was incorrectly deduplicating schemas with different validation constraints when using `anyOf`, resulting in incomplete union schemas. This fix ensures that schemas with different validation constraints (like `minLength`, `maxLength`, `minimum`, `maximum`, `pattern`, etc.) are properly preserved in unions. + +For example, with an `anyOf` containing strings with different length constraints: +- Before: `z.string().length(5)` (incorrect - only one constraint) +- After: `z.union([z.string().length(5), z.string().length(2)])` (correct - proper union) + +Fixes issue where the `deduplicateSchema` function was only considering `$ref`, `type`, `const`, and `format` when creating type identifiers, but ignored validation constraints. \ No newline at end of file -- 2.51.2 From 8bd26d53e09ac55afe8a1e1540a3043ffaccfd44 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 17 Sep 2025 22:51:54 +0800 Subject: [PATCH 16/19] Update fix-zod-union-deduplication.md --- .changeset/fix-zod-union-deduplication.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.changeset/fix-zod-union-deduplication.md b/.changeset/fix-zod-union-deduplication.md index 64126f8d3..a0c4ee6e1 100644 --- a/.changeset/fix-zod-union-deduplication.md +++ b/.changeset/fix-zod-union-deduplication.md @@ -2,12 +2,4 @@ "@hey-api/openapi-ts": patch --- -Fix Zod schema union deduplication by including validation constraints in type ID - -The Zod plugin was incorrectly deduplicating schemas with different validation constraints when using `anyOf`, resulting in incomplete union schemas. This fix ensures that schemas with different validation constraints (like `minLength`, `maxLength`, `minimum`, `maximum`, `pattern`, etc.) are properly preserved in unions. - -For example, with an `anyOf` containing strings with different length constraints: -- Before: `z.string().length(5)` (incorrect - only one constraint) -- After: `z.union([z.string().length(5), z.string().length(2)])` (correct - proper union) - -Fixes issue where the `deduplicateSchema` function was only considering `$ref`, `type`, `const`, and `format` when creating type identifiers, but ignored validation constraints. \ No newline at end of file +fix(parser): expand schema deduplication by including validation constraints in type ID -- 2.51.2 From dcfad92d980a43265fb9ae6316a1c0903ed0b07c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 18 Sep 2025 00:49:11 +0000 Subject: [PATCH 17/19] chore(docs): update contributors list --- docs/partials/contributors-list.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/partials/contributors-list.md b/docs/partials/contributors-list.md index 0f43a6f57..ccbf18c7d 100644 --- a/docs/partials/contributors-list.md +++ b/docs/partials/contributors-list.md @@ -75,6 +75,7 @@ - [carson](https://github.com/carson2222) - [johnny kim](https://github.com/johnny-mh) - [0xfurai](https://github.com/0xfurai) +- [Copilot](https://github.com/Copilot) - [Mxwllas](https://github.com/Mxwllas) - [RndUsername](https://github.com/RndUsername) - [Schroedi](https://github.com/Schroedi) -- 2.51.2 From c5ccac1f0621278733618dce0b85c4046bb9e843 Mon Sep 17 00:00:00 2001 From: Lubos Date: Sun, 21 Sep 2025 05:11:06 +0800 Subject: [PATCH 18/19] feat: placement api --- .../codegen-core/src/__tests__/bimap.test.ts | 66 + .../src/__tests__/bindings.test.ts | 226 +++ .../src/__tests__/{ => data}/file.ts | 0 .../src/__tests__/exports.test.ts | 29 + .../codegen-core/src/__tests__/file.test.ts | 232 ---- .../codegen-core/src/__tests__/files.test.ts | 94 ++ .../src/__tests__/project.test.ts | 211 ++- .../src/__tests__/renderer.test.ts | 17 +- .../src/__tests__/symbols.test.ts | 93 ++ packages/codegen-core/src/bimap/bimap.ts | 12 +- packages/codegen-core/src/bimap/types.d.ts | 2 +- .../src/{imports => bindings}/types.d.ts | 27 +- packages/codegen-core/src/bindings/utils.ts | 91 ++ .../codegen-core/src/extensions/types.d.ts | 17 + packages/codegen-core/src/files/file.ts | 283 ---- packages/codegen-core/src/files/registry.ts | 123 ++ packages/codegen-core/src/files/types.d.ts | 177 +-- packages/codegen-core/src/index.ts | 30 +- packages/codegen-core/src/meta/types.d.ts | 8 - packages/codegen-core/src/output/types.d.ts | 9 +- packages/codegen-core/src/project/project.ts | 324 ++--- packages/codegen-core/src/project/types.d.ts | 155 +-- packages/codegen-core/src/renderer/types.d.ts | 33 + .../renderer.ts => renderer/utils.ts} | 2 +- .../codegen-core/src/renderers/types.d.ts | 42 - .../codegen-core/src/selectors/types.d.ts | 7 + packages/codegen-core/src/symbols/registry.ts | 132 ++ packages/codegen-core/src/symbols/types.d.ts | 200 +-- packages/custom-client/src/plugin.ts | 10 +- .../additional-properties-false/index.ts | 2 +- .../additional-properties-false/types.gen.ts | 8 +- .../2.0.x/additional-properties-true/index.ts | 2 +- .../additional-properties-true/types.gen.ts | 8 +- .../body-response-text-plain/client.gen.ts | 8 +- .../2.0.x/body-response-text-plain/index.ts | 2 +- .../2.0.x/body-response-text-plain/sdk.gen.ts | 6 +- .../body-response-text-plain/types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../2.0.x/enum-names-values/index.ts | 2 +- .../2.0.x/enum-names-values/types.gen.ts | 8 +- .../2.0.x/exclude-deprecated/index.ts | 2 +- .../2.0.x/exclude-deprecated/types.gen.ts | 8 +- .../__snapshots__/2.0.x/external/index.ts | 2 +- .../__snapshots__/2.0.x/external/types.gen.ts | 8 +- .../2.0.x/form-data/client.gen.ts | 8 +- .../__snapshots__/2.0.x/form-data/index.ts | 2 +- .../__snapshots__/2.0.x/form-data/sdk.gen.ts | 6 +- .../2.0.x/form-data/types.gen.ts | 8 +- .../default-class/@angular/common.gen.ts | 794 +++++++++++ .../@angular/common/http/requests.gen.ts | 438 ------ .../@angular/common/http/resources.gen.ts | 362 ----- .../common/default-class/client.gen.ts | 8 +- .../@angular/common/default-class/index.ts | 2 +- .../@angular/common/default-class/sdk.gen.ts | 6 +- .../common/default-class/types.gen.ts | 8 +- .../http/requests.gen.ts => common.gen.ts} | 251 +++- .../@angular/common/http/resources.gen.ts | 248 ---- .../@angular/common/default/client.gen.ts | 8 +- .../plugins/@angular/common/default/index.ts | 2 +- .../@angular/common/default/sdk.gen.ts | 6 +- .../@angular/common/default/types.gen.ts | 8 +- .../sdk-nested-classes-instance/client.gen.ts | 8 +- .../sdk-nested-classes-instance/index.ts | 2 +- .../sdk-nested-classes-instance/sdk.gen.ts | 12 +- .../sdk-nested-classes-instance/types.gen.ts | 8 +- .../sdk-nested-classes/client.gen.ts | 8 +- .../client-fetch/sdk-nested-classes/index.ts | 2 +- .../sdk-nested-classes/sdk.gen.ts | 10 +- .../sdk-nested-classes/types.gen.ts | 8 +- .../@hey-api/sdk/default/client.gen.ts | 8 +- .../plugins/@hey-api/sdk/default/index.ts | 2 +- .../plugins/@hey-api/sdk/default/sdk.gen.ts | 6 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 8 +- .../@hey-api/sdk/instance/client.gen.ts | 8 +- .../plugins/@hey-api/sdk/instance/index.ts | 2 +- .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 10 +- .../@hey-api/sdk/instance/types.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/client.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/index.ts | 2 +- .../@hey-api/sdk/throwOnError/sdk.gen.ts | 6 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 8 +- .../type-format-valibot/client.gen.ts | 8 +- .../transformers/type-format-valibot/index.ts | 2 +- .../type-format-valibot/sdk.gen.ts | 11 +- .../type-format-valibot/transformers.gen.ts | 8 +- .../type-format-valibot/types.gen.ts | 16 +- .../type-format-zod/client.gen.ts | 8 +- .../transformers/type-format-zod/index.ts | 2 +- .../transformers/type-format-zod/sdk.gen.ts | 8 +- .../type-format-zod/transformers.gen.ts | 8 +- .../transformers/type-format-zod/types.gen.ts | 16 +- .../client.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../client.gen.ts | 8 +- .../transforms-read-write-ignore/index.ts | 2 +- .../transforms-read-write-ignore/types.gen.ts | 8 +- .../colada/asClass/@pinia/colada.gen.ts | 5 +- .../@pinia/colada/asClass/client.gen.ts | 8 +- .../plugins/@pinia/colada/asClass/index.ts | 2 +- .../plugins/@pinia/colada/asClass/sdk.gen.ts | 10 +- .../@pinia/colada/asClass/types.gen.ts | 8 +- .../@pinia/colada/fetch/@pinia/colada.gen.ts | 5 +- .../plugins/@pinia/colada/fetch/client.gen.ts | 8 +- .../plugins/@pinia/colada/fetch/index.ts | 2 +- .../plugins/@pinia/colada/fetch/sdk.gen.ts | 6 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../asClass/client.gen.ts | 8 +- .../asClass/index.ts | 2 +- .../asClass/sdk.gen.ts | 10 +- .../asClass/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../axios/client.gen.ts | 8 +- .../angular-query-experimental/axios/index.ts | 2 +- .../axios/sdk.gen.ts | 6 +- .../axios/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../fetch/client.gen.ts | 8 +- .../angular-query-experimental/fetch/index.ts | 2 +- .../fetch/sdk.gen.ts | 6 +- .../fetch/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../name-builder/client.gen.ts | 8 +- .../name-builder/index.ts | 2 +- .../name-builder/sdk.gen.ts | 6 +- .../name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/react-query.gen.ts | 5 +- .../react-query/asClass/client.gen.ts | 8 +- .../@tanstack/react-query/asClass/index.ts | 2 +- .../@tanstack/react-query/asClass/sdk.gen.ts | 10 +- .../react-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/react-query.gen.ts | 5 +- .../@tanstack/react-query/axios/client.gen.ts | 8 +- .../@tanstack/react-query/axios/index.ts | 2 +- .../@tanstack/react-query/axios/sdk.gen.ts | 6 +- .../@tanstack/react-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/react-query.gen.ts | 5 +- .../@tanstack/react-query/fetch/client.gen.ts | 8 +- .../@tanstack/react-query/fetch/index.ts | 2 +- .../@tanstack/react-query/fetch/sdk.gen.ts | 6 +- .../@tanstack/react-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/react-query.gen.ts | 5 +- .../react-query/name-builder/client.gen.ts | 8 +- .../react-query/name-builder/index.ts | 2 +- .../react-query/name-builder/sdk.gen.ts | 6 +- .../react-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/solid-query.gen.ts | 5 +- .../solid-query/asClass/client.gen.ts | 8 +- .../@tanstack/solid-query/asClass/index.ts | 2 +- .../@tanstack/solid-query/asClass/sdk.gen.ts | 10 +- .../solid-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/solid-query.gen.ts | 5 +- .../@tanstack/solid-query/axios/client.gen.ts | 8 +- .../@tanstack/solid-query/axios/index.ts | 2 +- .../@tanstack/solid-query/axios/sdk.gen.ts | 6 +- .../@tanstack/solid-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/solid-query.gen.ts | 5 +- .../@tanstack/solid-query/fetch/client.gen.ts | 8 +- .../@tanstack/solid-query/fetch/index.ts | 2 +- .../@tanstack/solid-query/fetch/sdk.gen.ts | 6 +- .../@tanstack/solid-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/solid-query.gen.ts | 5 +- .../solid-query/name-builder/client.gen.ts | 8 +- .../solid-query/name-builder/index.ts | 2 +- .../solid-query/name-builder/sdk.gen.ts | 6 +- .../solid-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/asClass/client.gen.ts | 8 +- .../@tanstack/svelte-query/asClass/index.ts | 2 +- .../@tanstack/svelte-query/asClass/sdk.gen.ts | 10 +- .../svelte-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/axios/client.gen.ts | 8 +- .../@tanstack/svelte-query/axios/index.ts | 2 +- .../@tanstack/svelte-query/axios/sdk.gen.ts | 6 +- .../@tanstack/svelte-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/fetch/client.gen.ts | 8 +- .../@tanstack/svelte-query/fetch/index.ts | 2 +- .../@tanstack/svelte-query/fetch/sdk.gen.ts | 6 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 8 +- .../@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/name-builder/client.gen.ts | 8 +- .../svelte-query/name-builder/index.ts | 2 +- .../svelte-query/name-builder/sdk.gen.ts | 6 +- .../svelte-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/vue-query.gen.ts | 5 +- .../@tanstack/vue-query/asClass/client.gen.ts | 8 +- .../@tanstack/vue-query/asClass/index.ts | 2 +- .../@tanstack/vue-query/asClass/sdk.gen.ts | 10 +- .../@tanstack/vue-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/vue-query.gen.ts | 5 +- .../@tanstack/vue-query/axios/client.gen.ts | 8 +- .../@tanstack/vue-query/axios/index.ts | 2 +- .../@tanstack/vue-query/axios/sdk.gen.ts | 6 +- .../@tanstack/vue-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/vue-query.gen.ts | 5 +- .../@tanstack/vue-query/fetch/client.gen.ts | 8 +- .../@tanstack/vue-query/fetch/index.ts | 2 +- .../@tanstack/vue-query/fetch/sdk.gen.ts | 6 +- .../@tanstack/vue-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/vue-query.gen.ts | 5 +- .../vue-query/name-builder/client.gen.ts | 8 +- .../@tanstack/vue-query/name-builder/index.ts | 2 +- .../vue-query/name-builder/sdk.gen.ts | 6 +- .../vue-query/name-builder/types.gen.ts | 8 +- .../plugins/fastify/default/fastify.gen.ts | 3 +- .../2.0.x/plugins/fastify/default/index.ts | 2 +- .../plugins/fastify/default/types.gen.ts | 8 +- .../2.0.x/schema-unknown/client.gen.ts | 8 +- .../2.0.x/schema-unknown/index.ts | 2 +- .../2.0.x/schema-unknown/sdk.gen.ts | 6 +- .../2.0.x/schema-unknown/types.gen.ts | 8 +- .../2.0.x/security-api-key/client.gen.ts | 8 +- .../2.0.x/security-api-key/index.ts | 2 +- .../2.0.x/security-api-key/sdk.gen.ts | 6 +- .../2.0.x/security-api-key/types.gen.ts | 8 +- .../2.0.x/security-basic/client.gen.ts | 8 +- .../2.0.x/security-basic/index.ts | 2 +- .../2.0.x/security-basic/sdk.gen.ts | 6 +- .../2.0.x/security-basic/types.gen.ts | 8 +- .../2.0.x/security-false/client.gen.ts | 8 +- .../2.0.x/security-false/index.ts | 2 +- .../2.0.x/security-false/sdk.gen.ts | 6 +- .../2.0.x/security-false/types.gen.ts | 8 +- .../2.0.x/security-oauth2/client.gen.ts | 8 +- .../2.0.x/security-oauth2/index.ts | 2 +- .../2.0.x/security-oauth2/sdk.gen.ts | 6 +- .../2.0.x/security-oauth2/types.gen.ts | 8 +- .../2.0.x/servers-base-path/client.gen.ts | 8 +- .../2.0.x/servers-base-path/index.ts | 2 +- .../2.0.x/servers-base-path/types.gen.ts | 8 +- .../2.0.x/servers-host/client.gen.ts | 8 +- .../__snapshots__/2.0.x/servers-host/index.ts | 2 +- .../2.0.x/servers-host/types.gen.ts | 8 +- .../__snapshots__/2.0.x/servers/client.gen.ts | 8 +- .../test/__snapshots__/2.0.x/servers/index.ts | 2 +- .../__snapshots__/2.0.x/servers/types.gen.ts | 8 +- .../2.0.x/transforms-read-write/client.gen.ts | 8 +- .../2.0.x/transforms-read-write/index.ts | 2 +- .../2.0.x/transforms-read-write/types.gen.ts | 8 +- .../additional-properties-false/index.ts | 2 +- .../additional-properties-false/types.gen.ts | 8 +- .../3.0.x/additional-properties-true/index.ts | 2 +- .../additional-properties-true/types.gen.ts | 8 +- .../additional-properties-undefined/index.ts | 2 +- .../types.gen.ts | 8 +- .../array-items-one-of-length-1/index.ts | 2 +- .../array-items-one-of-length-1/types.gen.ts | 8 +- .../3.0.x/array-nested-one-of/index.ts | 2 +- .../3.0.x/array-nested-one-of/types.gen.ts | 8 +- .../body-response-text-plain/client.gen.ts | 8 +- .../3.0.x/body-response-text-plain/index.ts | 2 +- .../3.0.x/body-response-text-plain/sdk.gen.ts | 6 +- .../body-response-text-plain/types.gen.ts | 8 +- .../3.0.x/case-PascalCase/index.ts | 2 +- .../3.0.x/case-PascalCase/types.gen.ts | 8 +- .../3.0.x/case-camelCase/index.ts | 2 +- .../3.0.x/case-camelCase/types.gen.ts | 8 +- .../3.0.x/case-preserve/index.ts | 2 +- .../3.0.x/case-preserve/types.gen.ts | 8 +- .../3.0.x/case-snake_case/index.ts | 2 +- .../3.0.x/case-snake_case/types.gen.ts | 8 +- .../3.0.x/components-request-bodies/index.ts | 2 +- .../components-request-bodies/types.gen.ts | 8 +- .../3.0.x/content-binary/index.ts | 2 +- .../3.0.x/content-binary/types.gen.ts | 8 +- .../3.0.x/content-types/client.gen.ts | 8 +- .../3.0.x/content-types/index.ts | 2 +- .../3.0.x/content-types/sdk.gen.ts | 6 +- .../3.0.x/content-types/types.gen.ts | 8 +- .../3.0.x/discriminator-all-of/index.ts | 2 +- .../3.0.x/discriminator-all-of/types.gen.ts | 8 +- .../3.0.x/discriminator-any-of/index.ts | 2 +- .../3.0.x/discriminator-any-of/types.gen.ts | 8 +- .../3.0.x/discriminator-mapped-many/index.ts | 2 +- .../discriminator-mapped-many/types.gen.ts | 8 +- .../3.0.x/discriminator-one-of/index.ts | 2 +- .../3.0.x/discriminator-one-of/types.gen.ts | 8 +- .../__snapshots__/3.0.x/enum-escape/index.ts | 2 +- .../3.0.x/enum-escape/types.gen.ts | 8 +- .../3.0.x/enum-inline-javascript/index.ts | 2 +- .../3.0.x/enum-inline-javascript/types.gen.ts | 8 +- .../3.0.x/enum-inline-typescript/index.ts | 2 +- .../3.0.x/enum-inline-typescript/types.gen.ts | 8 +- .../__snapshots__/3.0.x/enum-inline/index.ts | 2 +- .../3.0.x/enum-inline/types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../3.0.x/enum-names-values/index.ts | 2 +- .../3.0.x/enum-names-values/types.gen.ts | 8 +- .../__snapshots__/3.0.x/enum-null/index.ts | 2 +- .../3.0.x/enum-null/types.gen.ts | 8 +- .../3.0.x/exclude-deprecated/index.ts | 2 +- .../3.0.x/exclude-deprecated/types.gen.ts | 8 +- .../__snapshots__/3.0.x/external/index.ts | 2 +- .../__snapshots__/3.0.x/external/types.gen.ts | 8 +- .../@tanstack/react-query.gen.ts | 5 +- .../internal-name-conflict/client.gen.ts | 8 +- .../3.0.x/internal-name-conflict/index.ts | 2 +- .../3.0.x/internal-name-conflict/sdk.gen.ts | 6 +- .../3.0.x/internal-name-conflict/types.gen.ts | 8 +- .../3.0.x/operation-204/index.ts | 2 +- .../3.0.x/operation-204/types.gen.ts | 8 +- .../client.gen.ts | 8 +- .../parameter-explode-false-axios/index.ts | 2 +- .../parameter-explode-false-axios/sdk.gen.ts | 6 +- .../types.gen.ts | 8 +- .../parameter-explode-false/client.gen.ts | 8 +- .../3.0.x/parameter-explode-false/index.ts | 2 +- .../3.0.x/parameter-explode-false/sdk.gen.ts | 6 +- .../parameter-explode-false/types.gen.ts | 8 +- .../default-class/@angular/common.gen.ts | 1104 +++++++++++++++ .../@angular/common/http/requests.gen.ts | 607 --------- .../@angular/common/http/resources.gen.ts | 503 ------- .../common/default-class/client.gen.ts | 8 +- .../@angular/common/default-class/index.ts | 2 +- .../@angular/common/default-class/sdk.gen.ts | 8 +- .../common/default-class/types.gen.ts | 8 +- .../common/default/@angular/common.gen.ts | 787 +++++++++++ .../@angular/common/http/requests.gen.ts | 444 ------ .../@angular/common/http/resources.gen.ts | 348 ----- .../@angular/common/default/client.gen.ts | 8 +- .../plugins/@angular/common/default/index.ts | 2 +- .../@angular/common/default/sdk.gen.ts | 8 +- .../@angular/common/default/types.gen.ts | 8 +- .../sdk-nested-classes-instance/client.gen.ts | 8 +- .../sdk-nested-classes-instance/index.ts | 2 +- .../sdk-nested-classes-instance/sdk.gen.ts | 12 +- .../sdk-nested-classes-instance/types.gen.ts | 8 +- .../sdk-nested-classes/client.gen.ts | 8 +- .../client-fetch/sdk-nested-classes/index.ts | 2 +- .../sdk-nested-classes/sdk.gen.ts | 10 +- .../sdk-nested-classes/types.gen.ts | 8 +- .../@hey-api/sdk/default/client.gen.ts | 8 +- .../plugins/@hey-api/sdk/default/index.ts | 2 +- .../plugins/@hey-api/sdk/default/sdk.gen.ts | 8 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 8 +- .../@hey-api/sdk/instance/client.gen.ts | 8 +- .../plugins/@hey-api/sdk/instance/index.ts | 2 +- .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 10 +- .../@hey-api/sdk/instance/types.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/client.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/index.ts | 2 +- .../@hey-api/sdk/throwOnError/sdk.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 8 +- .../type-format-valibot/client.gen.ts | 8 +- .../transformers/type-format-valibot/index.ts | 2 +- .../type-format-valibot/sdk.gen.ts | 11 +- .../type-format-valibot/transformers.gen.ts | 8 +- .../type-format-valibot/types.gen.ts | 16 +- .../type-format-zod/client.gen.ts | 8 +- .../transformers/type-format-zod/index.ts | 2 +- .../transformers/type-format-zod/sdk.gen.ts | 8 +- .../type-format-zod/transformers.gen.ts | 8 +- .../transformers/type-format-zod/types.gen.ts | 16 +- .../client.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../client.gen.ts | 8 +- .../transforms-read-write-ignore/index.ts | 2 +- .../transforms-read-write-ignore/types.gen.ts | 8 +- .../colada/asClass/@pinia/colada.gen.ts | 5 +- .../@pinia/colada/asClass/client.gen.ts | 8 +- .../plugins/@pinia/colada/asClass/index.ts | 2 +- .../plugins/@pinia/colada/asClass/sdk.gen.ts | 10 +- .../@pinia/colada/asClass/types.gen.ts | 8 +- .../@pinia/colada/fetch/@pinia/colada.gen.ts | 7 +- .../plugins/@pinia/colada/fetch/client.gen.ts | 8 +- .../plugins/@pinia/colada/fetch/index.ts | 2 +- .../plugins/@pinia/colada/fetch/sdk.gen.ts | 8 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../asClass/client.gen.ts | 8 +- .../asClass/index.ts | 2 +- .../asClass/sdk.gen.ts | 10 +- .../asClass/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 9 +- .../axios/client.gen.ts | 8 +- .../angular-query-experimental/axios/index.ts | 2 +- .../axios/sdk.gen.ts | 8 +- .../axios/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 9 +- .../fetch/client.gen.ts | 8 +- .../angular-query-experimental/fetch/index.ts | 2 +- .../fetch/sdk.gen.ts | 8 +- .../fetch/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../name-builder/client.gen.ts | 8 +- .../name-builder/index.ts | 2 +- .../name-builder/sdk.gen.ts | 6 +- .../name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/react-query.gen.ts | 5 +- .../react-query/asClass/client.gen.ts | 8 +- .../@tanstack/react-query/asClass/index.ts | 2 +- .../@tanstack/react-query/asClass/sdk.gen.ts | 10 +- .../react-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/react-query.gen.ts | 9 +- .../@tanstack/react-query/axios/client.gen.ts | 8 +- .../@tanstack/react-query/axios/index.ts | 2 +- .../@tanstack/react-query/axios/sdk.gen.ts | 8 +- .../@tanstack/react-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/react-query.gen.ts | 9 +- .../@tanstack/react-query/fetch/client.gen.ts | 8 +- .../@tanstack/react-query/fetch/index.ts | 2 +- .../@tanstack/react-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/react-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/react-query.gen.ts | 5 +- .../react-query/name-builder/client.gen.ts | 8 +- .../react-query/name-builder/index.ts | 2 +- .../react-query/name-builder/sdk.gen.ts | 6 +- .../react-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/solid-query.gen.ts | 5 +- .../solid-query/asClass/client.gen.ts | 8 +- .../@tanstack/solid-query/asClass/index.ts | 2 +- .../@tanstack/solid-query/asClass/sdk.gen.ts | 10 +- .../solid-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/solid-query.gen.ts | 9 +- .../@tanstack/solid-query/axios/client.gen.ts | 8 +- .../@tanstack/solid-query/axios/index.ts | 2 +- .../@tanstack/solid-query/axios/sdk.gen.ts | 8 +- .../@tanstack/solid-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/solid-query.gen.ts | 9 +- .../@tanstack/solid-query/fetch/client.gen.ts | 8 +- .../@tanstack/solid-query/fetch/index.ts | 2 +- .../@tanstack/solid-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/solid-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/solid-query.gen.ts | 5 +- .../solid-query/name-builder/client.gen.ts | 8 +- .../solid-query/name-builder/index.ts | 2 +- .../solid-query/name-builder/sdk.gen.ts | 6 +- .../solid-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/asClass/client.gen.ts | 8 +- .../@tanstack/svelte-query/asClass/index.ts | 2 +- .../@tanstack/svelte-query/asClass/sdk.gen.ts | 10 +- .../svelte-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/svelte-query.gen.ts | 9 +- .../svelte-query/axios/client.gen.ts | 8 +- .../@tanstack/svelte-query/axios/index.ts | 2 +- .../@tanstack/svelte-query/axios/sdk.gen.ts | 8 +- .../@tanstack/svelte-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/svelte-query.gen.ts | 9 +- .../svelte-query/fetch/client.gen.ts | 8 +- .../@tanstack/svelte-query/fetch/index.ts | 2 +- .../@tanstack/svelte-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 8 +- .../@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/name-builder/client.gen.ts | 8 +- .../svelte-query/name-builder/index.ts | 2 +- .../svelte-query/name-builder/sdk.gen.ts | 6 +- .../svelte-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/vue-query.gen.ts | 5 +- .../@tanstack/vue-query/asClass/client.gen.ts | 8 +- .../@tanstack/vue-query/asClass/index.ts | 2 +- .../@tanstack/vue-query/asClass/sdk.gen.ts | 10 +- .../@tanstack/vue-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/vue-query.gen.ts | 9 +- .../@tanstack/vue-query/axios/client.gen.ts | 8 +- .../@tanstack/vue-query/axios/index.ts | 2 +- .../@tanstack/vue-query/axios/sdk.gen.ts | 8 +- .../@tanstack/vue-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/vue-query.gen.ts | 9 +- .../@tanstack/vue-query/fetch/client.gen.ts | 8 +- .../@tanstack/vue-query/fetch/index.ts | 2 +- .../@tanstack/vue-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/vue-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/vue-query.gen.ts | 5 +- .../vue-query/name-builder/client.gen.ts | 8 +- .../@tanstack/vue-query/name-builder/index.ts | 2 +- .../vue-query/name-builder/sdk.gen.ts | 6 +- .../vue-query/name-builder/types.gen.ts | 8 +- .../plugins/fastify/default/fastify.gen.ts | 7 +- .../3.0.x/plugins/fastify/default/index.ts | 2 +- .../plugins/fastify/default/types.gen.ts | 8 +- .../3.0.x/security-api-key/client.gen.ts | 8 +- .../3.0.x/security-api-key/index.ts | 2 +- .../3.0.x/security-api-key/sdk.gen.ts | 6 +- .../3.0.x/security-api-key/types.gen.ts | 8 +- .../3.0.x/security-false/client.gen.ts | 8 +- .../3.0.x/security-false/index.ts | 2 +- .../3.0.x/security-false/sdk.gen.ts | 6 +- .../3.0.x/security-false/types.gen.ts | 8 +- .../3.0.x/security-http-bearer/client.gen.ts | 8 +- .../3.0.x/security-http-bearer/index.ts | 2 +- .../3.0.x/security-http-bearer/sdk.gen.ts | 6 +- .../3.0.x/security-http-bearer/types.gen.ts | 8 +- .../3.0.x/security-oauth2/client.gen.ts | 8 +- .../3.0.x/security-oauth2/index.ts | 2 +- .../3.0.x/security-oauth2/sdk.gen.ts | 6 +- .../3.0.x/security-oauth2/types.gen.ts | 8 +- .../security-open-id-connect/client.gen.ts | 8 +- .../3.0.x/security-open-id-connect/index.ts | 2 +- .../3.0.x/security-open-id-connect/sdk.gen.ts | 6 +- .../security-open-id-connect/types.gen.ts | 8 +- .../__snapshots__/3.0.x/servers/client.gen.ts | 8 +- .../test/__snapshots__/3.0.x/servers/index.ts | 2 +- .../__snapshots__/3.0.x/servers/types.gen.ts | 8 +- .../3.0.x/transformers-all-of/client.gen.ts | 8 +- .../3.0.x/transformers-all-of/index.ts | 2 +- .../transformers-all-of/transformers.gen.ts | 26 +- .../3.0.x/transformers-all-of/types.gen.ts | 8 +- .../transformers-any-of-null/client.gen.ts | 8 +- .../3.0.x/transformers-any-of-null/index.ts | 2 +- .../transformers.gen.ts | 14 +- .../transformers-any-of-null/types.gen.ts | 8 +- .../3.0.x/transformers-array/client.gen.ts | 8 +- .../3.0.x/transformers-array/index.ts | 2 +- .../3.0.x/transformers-array/types.gen.ts | 8 +- .../3.0.x/transforms-read-write/client.gen.ts | 8 +- .../3.0.x/transforms-read-write/index.ts | 2 +- .../3.0.x/transforms-read-write/types.gen.ts | 8 +- .../__snapshots__/3.0.x/type-invalid/index.ts | 2 +- .../3.0.x/type-invalid/types.gen.ts | 4 +- .../additional-properties-false/index.ts | 2 +- .../additional-properties-false/types.gen.ts | 8 +- .../additional-properties-true-any/index.ts | 2 +- .../types.gen.ts | 8 +- .../3.1.x/additional-properties-true/index.ts | 2 +- .../additional-properties-true/types.gen.ts | 8 +- .../additional-properties-undefined/index.ts | 2 +- .../types.gen.ts | 8 +- .../array-items-one-of-length-1/index.ts | 2 +- .../array-items-one-of-length-1/types.gen.ts | 8 +- .../3.1.x/array-nested-one-of/index.ts | 2 +- .../3.1.x/array-nested-one-of/types.gen.ts | 8 +- .../body-response-text-plain/client.gen.ts | 8 +- .../3.1.x/body-response-text-plain/index.ts | 2 +- .../3.1.x/body-response-text-plain/sdk.gen.ts | 6 +- .../body-response-text-plain/types.gen.ts | 8 +- .../3.1.x/case-PascalCase/index.ts | 2 +- .../3.1.x/case-PascalCase/types.gen.ts | 8 +- .../3.1.x/case-camelCase/index.ts | 2 +- .../3.1.x/case-camelCase/types.gen.ts | 8 +- .../3.1.x/case-preserve/index.ts | 2 +- .../3.1.x/case-preserve/types.gen.ts | 8 +- .../3.1.x/case-snake_case/index.ts | 2 +- .../3.1.x/case-snake_case/types.gen.ts | 8 +- .../client-axios/base-url-false/client.gen.ts | 8 +- .../client-axios/base-url-false/index.ts | 2 +- .../client-axios/base-url-false/types.gen.ts | 8 +- .../base-url-number/client.gen.ts | 8 +- .../client-axios/base-url-number/index.ts | 2 +- .../client-axios/base-url-number/types.gen.ts | 8 +- .../base-url-strict/client.gen.ts | 8 +- .../client-axios/base-url-strict/index.ts | 2 +- .../client-axios/base-url-strict/types.gen.ts | 8 +- .../base-url-string/client.gen.ts | 8 +- .../client-axios/base-url-string/index.ts | 2 +- .../client-axios/base-url-string/types.gen.ts | 8 +- .../client-axios/clean-false/client.gen.ts | 8 +- .../client-axios/clean-false/index.ts | 2 +- .../client-axios/clean-false/sdk.gen.ts | 8 +- .../client-axios/clean-false/types.gen.ts | 8 +- .../client-axios/default/client.gen.ts | 8 +- .../@hey-api/client-axios/default/index.ts | 2 +- .../@hey-api/client-axios/default/sdk.gen.ts | 8 +- .../client-axios/default/types.gen.ts | 8 +- .../sdk-client-optional/client.gen.ts | 8 +- .../client-axios/sdk-client-optional/index.ts | 2 +- .../sdk-client-optional/sdk.gen.ts | 8 +- .../sdk-client-optional/types.gen.ts | 8 +- .../sdk-client-required/client.gen.ts | 8 +- .../client-axios/sdk-client-required/index.ts | 2 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 8 +- .../tsconfig-nodenext-sdk/client.gen.ts | 8 +- .../tsconfig-nodenext-sdk/index.ts | 2 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 8 +- .../tsconfig-nodenext-sdk/types.gen.ts | 8 +- .../client-fetch/base-url-false/client.gen.ts | 8 +- .../client-fetch/base-url-false/index.ts | 2 +- .../client-fetch/base-url-false/types.gen.ts | 8 +- .../base-url-number/client.gen.ts | 8 +- .../client-fetch/base-url-number/index.ts | 2 +- .../client-fetch/base-url-number/types.gen.ts | 8 +- .../base-url-strict/client.gen.ts | 8 +- .../client-fetch/base-url-strict/index.ts | 2 +- .../client-fetch/base-url-strict/types.gen.ts | 8 +- .../base-url-string/client.gen.ts | 8 +- .../client-fetch/base-url-string/index.ts | 2 +- .../client-fetch/base-url-string/types.gen.ts | 8 +- .../client-fetch/clean-false/client.gen.ts | 8 +- .../client-fetch/clean-false/index.ts | 2 +- .../client-fetch/clean-false/sdk.gen.ts | 8 +- .../client-fetch/clean-false/types.gen.ts | 8 +- .../client-fetch/default/client.gen.ts | 8 +- .../@hey-api/client-fetch/default/index.ts | 2 +- .../@hey-api/client-fetch/default/sdk.gen.ts | 8 +- .../client-fetch/default/types.gen.ts | 8 +- .../sdk-client-optional/client.gen.ts | 8 +- .../client-fetch/sdk-client-optional/index.ts | 2 +- .../sdk-client-optional/sdk.gen.ts | 8 +- .../sdk-client-optional/types.gen.ts | 8 +- .../sdk-client-required/client.gen.ts | 8 +- .../client-fetch/sdk-client-required/index.ts | 2 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 8 +- .../tsconfig-nodenext-sdk/client.gen.ts | 8 +- .../tsconfig-nodenext-sdk/index.ts | 2 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 8 +- .../tsconfig-nodenext-sdk/types.gen.ts | 8 +- .../client-next/base-url-false/client.gen.ts | 8 +- .../client-next/base-url-false/index.ts | 2 +- .../client-next/base-url-false/types.gen.ts | 8 +- .../client-next/base-url-number/client.gen.ts | 8 +- .../client-next/base-url-number/index.ts | 2 +- .../client-next/base-url-number/types.gen.ts | 8 +- .../client-next/base-url-strict/client.gen.ts | 8 +- .../client-next/base-url-strict/index.ts | 2 +- .../client-next/base-url-strict/types.gen.ts | 8 +- .../client-next/base-url-string/client.gen.ts | 8 +- .../client-next/base-url-string/index.ts | 2 +- .../client-next/base-url-string/types.gen.ts | 8 +- .../client-next/clean-false/client.gen.ts | 8 +- .../@hey-api/client-next/clean-false/index.ts | 2 +- .../client-next/clean-false/sdk.gen.ts | 8 +- .../client-next/clean-false/types.gen.ts | 8 +- .../client-next/default/client.gen.ts | 8 +- .../@hey-api/client-next/default/index.ts | 2 +- .../@hey-api/client-next/default/sdk.gen.ts | 8 +- .../@hey-api/client-next/default/types.gen.ts | 8 +- .../sdk-client-optional/client.gen.ts | 8 +- .../client-next/sdk-client-optional/index.ts | 2 +- .../sdk-client-optional/sdk.gen.ts | 8 +- .../sdk-client-optional/types.gen.ts | 8 +- .../sdk-client-required/client.gen.ts | 8 +- .../client-next/sdk-client-required/index.ts | 2 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 8 +- .../tsconfig-nodenext-sdk/client.gen.ts | 8 +- .../tsconfig-nodenext-sdk/index.ts | 2 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 8 +- .../tsconfig-nodenext-sdk/types.gen.ts | 8 +- .../client-nuxt/base-url-false/client.gen.ts | 8 +- .../client-nuxt/base-url-false/index.ts | 2 +- .../client-nuxt/base-url-false/types.gen.ts | 8 +- .../client-nuxt/base-url-number/client.gen.ts | 8 +- .../client-nuxt/base-url-number/index.ts | 2 +- .../client-nuxt/base-url-number/types.gen.ts | 8 +- .../client-nuxt/base-url-strict/client.gen.ts | 8 +- .../client-nuxt/base-url-strict/index.ts | 2 +- .../client-nuxt/base-url-strict/types.gen.ts | 8 +- .../client-nuxt/base-url-string/client.gen.ts | 8 +- .../client-nuxt/base-url-string/index.ts | 2 +- .../client-nuxt/base-url-string/types.gen.ts | 8 +- .../client-nuxt/clean-false/client.gen.ts | 8 +- .../@hey-api/client-nuxt/clean-false/index.ts | 2 +- .../client-nuxt/clean-false/sdk.gen.ts | 8 +- .../client-nuxt/clean-false/types.gen.ts | 8 +- .../client-nuxt/default/client.gen.ts | 8 +- .../@hey-api/client-nuxt/default/index.ts | 2 +- .../@hey-api/client-nuxt/default/sdk.gen.ts | 8 +- .../@hey-api/client-nuxt/default/types.gen.ts | 8 +- .../sdk-client-optional/client.gen.ts | 8 +- .../client-nuxt/sdk-client-optional/index.ts | 2 +- .../sdk-client-optional/sdk.gen.ts | 8 +- .../sdk-client-optional/types.gen.ts | 8 +- .../sdk-client-required/client.gen.ts | 8 +- .../client-nuxt/sdk-client-required/index.ts | 2 +- .../sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 8 +- .../tsconfig-nodenext-sdk/client.gen.ts | 8 +- .../tsconfig-nodenext-sdk/index.ts | 2 +- .../tsconfig-nodenext-sdk/sdk.gen.ts | 8 +- .../tsconfig-nodenext-sdk/types.gen.ts | 8 +- .../base-url-false/custom-client.gen.ts} | 9 +- .../client-custom/base-url-false/index.ts | 2 +- .../client-custom/base-url-false/types.gen.ts | 8 +- .../base-url-number/client.gen.ts | 18 - .../custom-client.gen.ts} | 9 +- .../client-custom/base-url-number/index.ts | 2 +- .../base-url-number/types.gen.ts | 8 +- .../base-url-strict/client.gen.ts | 18 - .../base-url-strict/custom-client.gen.ts} | 9 +- .../client-custom/base-url-strict/index.ts | 2 +- .../base-url-strict/types.gen.ts | 8 +- .../base-url-string/custom-client.gen.ts} | 9 +- .../client-custom/base-url-string/index.ts | 2 +- .../base-url-string/types.gen.ts | 8 +- .../client-custom/bundle/custom-client.gen.ts | 18 + .../clients/client-custom/bundle/index.ts | 2 +- .../clients/client-custom/bundle/sdk.gen.ts | 10 +- .../clients/client-custom/bundle/types.gen.ts | 8 +- .../client-custom/default/client.gen.ts | 18 - .../default/custom-client.gen.ts} | 9 +- .../clients/client-custom/default/index.ts | 2 +- .../clients/client-custom/default/sdk.gen.ts | 11 +- .../client-custom/default/types.gen.ts | 8 +- .../sdk-client-optional/client.gen.ts | 18 - .../sdk-client-optional/custom-client.gen.ts} | 9 +- .../sdk-client-optional/index.ts | 2 +- .../sdk-client-optional/sdk.gen.ts | 11 +- .../sdk-client-optional/types.gen.ts | 8 +- .../sdk-client-required/client.gen.ts | 18 - .../sdk-client-required/custom-client.gen.ts | 19 + .../sdk-client-required/index.ts | 2 +- .../sdk-client-required/sdk.gen.ts | 9 +- .../sdk-client-required/types.gen.ts | 8 +- .../my-client/base-url-false/client/plugin.ts | 12 +- .../base-url-false/custom.gen.ts} | 8 +- .../clients/my-client/base-url-false/index.ts | 2 +- .../my-client/base-url-false/types.gen.ts | 8 +- .../base-url-number/client/plugin.ts | 12 +- .../my-client/base-url-number/custom.gen.ts | 18 + .../my-client/base-url-number/index.ts | 2 +- .../my-client/base-url-number/types.gen.ts | 8 +- .../base-url-strict/client/plugin.ts | 12 +- .../my-client/base-url-strict/custom.gen.ts | 18 + .../my-client/base-url-strict/index.ts | 2 +- .../my-client/base-url-strict/types.gen.ts | 8 +- .../base-url-string/client/plugin.ts | 12 +- .../base-url-string/custom.gen.ts} | 8 +- .../my-client/base-url-string/index.ts | 2 +- .../my-client/base-url-string/types.gen.ts | 8 +- .../clients/my-client/bundle/client/plugin.ts | 12 +- .../clients/my-client/bundle/custom.gen.ts | 18 + .../3.1.x/clients/my-client/bundle/index.ts | 2 +- .../3.1.x/clients/my-client/bundle/sdk.gen.ts | 10 +- .../clients/my-client/bundle/types.gen.ts | 8 +- .../clients/my-client/default/client.gen.ts | 18 - .../my-client/default/client/plugin.ts | 12 +- .../clients/my-client/default/custom.gen.ts | 18 + .../3.1.x/clients/my-client/default/index.ts | 2 +- .../clients/my-client/default/sdk.gen.ts | 10 +- .../clients/my-client/default/types.gen.ts | 8 +- .../sdk-client-optional/client.gen.ts | 18 - .../sdk-client-optional/client/plugin.ts | 12 +- .../sdk-client-optional/custom.gen.ts | 18 + .../my-client/sdk-client-optional/index.ts | 2 +- .../my-client/sdk-client-optional/sdk.gen.ts | 10 +- .../sdk-client-optional/types.gen.ts | 8 +- .../sdk-client-required/client.gen.ts | 18 - .../sdk-client-required/client/plugin.ts | 12 +- .../sdk-client-required/custom.gen.ts | 18 + .../my-client/sdk-client-required/index.ts | 2 +- .../my-client/sdk-client-required/sdk.gen.ts | 8 +- .../sdk-client-required/types.gen.ts | 8 +- .../3.1.x/components-request-bodies/index.ts | 2 +- .../components-request-bodies/types.gen.ts | 8 +- .../test/__snapshots__/3.1.x/const/index.ts | 2 +- .../__snapshots__/3.1.x/const/types.gen.ts | 8 +- .../3.1.x/content-binary/index.ts | 2 +- .../3.1.x/content-binary/types.gen.ts | 8 +- .../3.1.x/content-types/client.gen.ts | 8 +- .../3.1.x/content-types/index.ts | 2 +- .../3.1.x/content-types/sdk.gen.ts | 6 +- .../3.1.x/content-types/types.gen.ts | 8 +- .../3.1.x/discriminator-all-of/index.ts | 2 +- .../3.1.x/discriminator-all-of/types.gen.ts | 8 +- .../3.1.x/discriminator-any-of/index.ts | 2 +- .../3.1.x/discriminator-any-of/types.gen.ts | 8 +- .../3.1.x/discriminator-mapped-many/index.ts | 2 +- .../discriminator-mapped-many/types.gen.ts | 8 +- .../3.1.x/discriminator-one-of/index.ts | 2 +- .../3.1.x/discriminator-one-of/types.gen.ts | 8 +- .../3.1.x/duplicate-null/index.ts | 2 +- .../3.1.x/duplicate-null/types.gen.ts | 8 +- .../__snapshots__/3.1.x/enum-escape/index.ts | 2 +- .../3.1.x/enum-escape/types.gen.ts | 8 +- .../3.1.x/enum-inline-javascript/index.ts | 2 +- .../3.1.x/enum-inline-javascript/types.gen.ts | 8 +- .../3.1.x/enum-inline-typescript/index.ts | 2 +- .../3.1.x/enum-inline-typescript/types.gen.ts | 8 +- .../__snapshots__/3.1.x/enum-inline/index.ts | 2 +- .../3.1.x/enum-inline/types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../3.1.x/enum-names-values/index.ts | 2 +- .../3.1.x/enum-names-values/types.gen.ts | 8 +- .../__snapshots__/3.1.x/enum-null/index.ts | 2 +- .../3.1.x/enum-null/types.gen.ts | 8 +- .../3.1.x/exclude-deprecated/index.ts | 2 +- .../3.1.x/exclude-deprecated/types.gen.ts | 8 +- .../__snapshots__/3.1.x/external/index.ts | 2 +- .../__snapshots__/3.1.x/external/types.gen.ts | 8 +- .../__snapshots__/3.1.x/headers/client.gen.ts | 8 +- .../test/__snapshots__/3.1.x/headers/index.ts | 2 +- .../__snapshots__/3.1.x/headers/sdk.gen.ts | 6 +- .../__snapshots__/3.1.x/headers/types.gen.ts | 8 +- .../@tanstack/react-query.gen.ts | 5 +- .../internal-name-conflict/client.gen.ts | 8 +- .../3.1.x/internal-name-conflict/index.ts | 2 +- .../3.1.x/internal-name-conflict/sdk.gen.ts | 6 +- .../3.1.x/internal-name-conflict/types.gen.ts | 8 +- .../3.1.x/negative-property-names/index.ts | 2 +- .../negative-property-names/types.gen.ts | 8 +- .../3.1.x/object-properties-all-of/index.ts | 2 +- .../object-properties-all-of/types.gen.ts | 8 +- .../3.1.x/object-properties-any-of/index.ts | 2 +- .../object-properties-any-of/types.gen.ts | 8 +- .../3.1.x/object-properties-one-of/index.ts | 2 +- .../object-properties-one-of/types.gen.ts | 8 +- .../3.1.x/object-property-names/index.ts | 2 +- .../3.1.x/object-property-names/types.gen.ts | 8 +- .../3.1.x/operation-204/index.ts | 2 +- .../3.1.x/operation-204/types.gen.ts | 8 +- .../@tanstack/react-query.gen.ts | 5 +- .../3.1.x/pagination-ref/client.gen.ts | 8 +- .../3.1.x/pagination-ref/index.ts | 2 +- .../3.1.x/pagination-ref/sdk.gen.ts | 6 +- .../3.1.x/pagination-ref/types.gen.ts | 8 +- .../client.gen.ts | 8 +- .../parameter-explode-false-axios/index.ts | 2 +- .../parameter-explode-false-axios/sdk.gen.ts | 6 +- .../types.gen.ts | 8 +- .../parameter-explode-false/client.gen.ts | 8 +- .../3.1.x/parameter-explode-false/index.ts | 2 +- .../3.1.x/parameter-explode-false/sdk.gen.ts | 6 +- .../parameter-explode-false/types.gen.ts | 8 +- .../3.1.x/parameter-tuple/index.ts | 2 +- .../3.1.x/parameter-tuple/types.gen.ts | 8 +- .../3.1.x/pattern-properties/index.ts | 2 +- .../3.1.x/pattern-properties/types.gen.ts | 8 +- .../default-class/@angular/common.gen.ts | 1104 +++++++++++++++ .../@angular/common/http/requests.gen.ts | 607 --------- .../@angular/common/http/resources.gen.ts | 503 ------- .../common/default-class/client.gen.ts | 8 +- .../@angular/common/default-class/index.ts | 2 +- .../@angular/common/default-class/sdk.gen.ts | 8 +- .../common/default-class/types.gen.ts | 8 +- .../common/default/@angular/common.gen.ts | 787 +++++++++++ .../@angular/common/http/requests.gen.ts | 444 ------ .../@angular/common/http/resources.gen.ts | 348 ----- .../@angular/common/default/client.gen.ts | 8 +- .../plugins/@angular/common/default/index.ts | 2 +- .../@angular/common/default/sdk.gen.ts | 8 +- .../@angular/common/default/types.gen.ts | 8 +- .../sdk-nested-classes-instance/client.gen.ts | 8 +- .../sdk-nested-classes-instance/index.ts | 2 +- .../sdk-nested-classes-instance/sdk.gen.ts | 12 +- .../sdk-nested-classes-instance/types.gen.ts | 8 +- .../sdk-nested-classes/client.gen.ts | 8 +- .../client-fetch/sdk-nested-classes/index.ts | 2 +- .../sdk-nested-classes/sdk.gen.ts | 10 +- .../sdk-nested-classes/types.gen.ts | 8 +- .../@hey-api/sdk/default/client.gen.ts | 8 +- .../plugins/@hey-api/sdk/default/index.ts | 2 +- .../plugins/@hey-api/sdk/default/sdk.gen.ts | 8 +- .../plugins/@hey-api/sdk/default/types.gen.ts | 8 +- .../@hey-api/sdk/instance/client.gen.ts | 8 +- .../plugins/@hey-api/sdk/instance/index.ts | 2 +- .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 10 +- .../@hey-api/sdk/instance/types.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/client.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/index.ts | 2 +- .../@hey-api/sdk/throwOnError/sdk.gen.ts | 8 +- .../@hey-api/sdk/throwOnError/types.gen.ts | 8 +- .../type-format-valibot/client.gen.ts | 8 +- .../transformers/type-format-valibot/index.ts | 2 +- .../type-format-valibot/sdk.gen.ts | 11 +- .../type-format-valibot/transformers.gen.ts | 8 +- .../type-format-valibot/types.gen.ts | 16 +- .../type-format-zod/client.gen.ts | 8 +- .../transformers/type-format-zod/index.ts | 2 +- .../transformers/type-format-zod/sdk.gen.ts | 8 +- .../type-format-zod/transformers.gen.ts | 8 +- .../transformers/type-format-zod/types.gen.ts | 16 +- .../client.gen.ts | 8 +- .../index.ts | 2 +- .../types.gen.ts | 8 +- .../client.gen.ts | 8 +- .../transforms-read-write-ignore/index.ts | 2 +- .../transforms-read-write-ignore/types.gen.ts | 8 +- .../colada/asClass/@pinia/colada.gen.ts | 5 +- .../@pinia/colada/asClass/client.gen.ts | 8 +- .../plugins/@pinia/colada/asClass/index.ts | 2 +- .../plugins/@pinia/colada/asClass/sdk.gen.ts | 10 +- .../@pinia/colada/asClass/types.gen.ts | 8 +- .../@pinia/colada/fetch/@pinia/colada.gen.ts | 7 +- .../plugins/@pinia/colada/fetch/client.gen.ts | 8 +- .../plugins/@pinia/colada/fetch/index.ts | 2 +- .../plugins/@pinia/colada/fetch/sdk.gen.ts | 8 +- .../plugins/@pinia/colada/fetch/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../asClass/client.gen.ts | 8 +- .../asClass/index.ts | 2 +- .../asClass/sdk.gen.ts | 10 +- .../asClass/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 9 +- .../axios/client.gen.ts | 8 +- .../angular-query-experimental/axios/index.ts | 2 +- .../axios/sdk.gen.ts | 8 +- .../axios/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 9 +- .../fetch/client.gen.ts | 8 +- .../angular-query-experimental/fetch/index.ts | 2 +- .../fetch/sdk.gen.ts | 8 +- .../fetch/types.gen.ts | 8 +- .../angular-query-experimental.gen.ts | 5 +- .../name-builder/client.gen.ts | 8 +- .../name-builder/index.ts | 2 +- .../name-builder/sdk.gen.ts | 6 +- .../name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/react-query.gen.ts | 5 +- .../react-query/asClass/client.gen.ts | 8 +- .../@tanstack/react-query/asClass/index.ts | 2 +- .../@tanstack/react-query/asClass/sdk.gen.ts | 10 +- .../react-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/react-query.gen.ts | 9 +- .../@tanstack/react-query/axios/client.gen.ts | 8 +- .../@tanstack/react-query/axios/index.ts | 2 +- .../@tanstack/react-query/axios/sdk.gen.ts | 8 +- .../@tanstack/react-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/react-query.gen.ts | 9 +- .../@tanstack/react-query/fetch/client.gen.ts | 8 +- .../@tanstack/react-query/fetch/index.ts | 2 +- .../@tanstack/react-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/react-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/react-query.gen.ts | 5 +- .../react-query/name-builder/client.gen.ts | 8 +- .../react-query/name-builder/index.ts | 2 +- .../react-query/name-builder/sdk.gen.ts | 6 +- .../react-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/solid-query.gen.ts | 5 +- .../solid-query/asClass/client.gen.ts | 8 +- .../@tanstack/solid-query/asClass/index.ts | 2 +- .../@tanstack/solid-query/asClass/sdk.gen.ts | 10 +- .../solid-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/solid-query.gen.ts | 9 +- .../@tanstack/solid-query/axios/client.gen.ts | 8 +- .../@tanstack/solid-query/axios/index.ts | 2 +- .../@tanstack/solid-query/axios/sdk.gen.ts | 8 +- .../@tanstack/solid-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/solid-query.gen.ts | 9 +- .../@tanstack/solid-query/fetch/client.gen.ts | 8 +- .../@tanstack/solid-query/fetch/index.ts | 2 +- .../@tanstack/solid-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/solid-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/solid-query.gen.ts | 5 +- .../solid-query/name-builder/client.gen.ts | 8 +- .../solid-query/name-builder/index.ts | 2 +- .../solid-query/name-builder/sdk.gen.ts | 6 +- .../solid-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/asClass/client.gen.ts | 8 +- .../@tanstack/svelte-query/asClass/index.ts | 2 +- .../@tanstack/svelte-query/asClass/sdk.gen.ts | 10 +- .../svelte-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/svelte-query.gen.ts | 9 +- .../svelte-query/axios/client.gen.ts | 8 +- .../@tanstack/svelte-query/axios/index.ts | 2 +- .../@tanstack/svelte-query/axios/sdk.gen.ts | 8 +- .../@tanstack/svelte-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/svelte-query.gen.ts | 9 +- .../svelte-query/fetch/client.gen.ts | 8 +- .../@tanstack/svelte-query/fetch/index.ts | 2 +- .../@tanstack/svelte-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/svelte-query/fetch/types.gen.ts | 8 +- .../@tanstack/svelte-query.gen.ts | 5 +- .../svelte-query/name-builder/client.gen.ts | 8 +- .../svelte-query/name-builder/index.ts | 2 +- .../svelte-query/name-builder/sdk.gen.ts | 6 +- .../svelte-query/name-builder/types.gen.ts | 8 +- .../asClass/@tanstack/vue-query.gen.ts | 5 +- .../@tanstack/vue-query/asClass/client.gen.ts | 8 +- .../@tanstack/vue-query/asClass/index.ts | 2 +- .../@tanstack/vue-query/asClass/sdk.gen.ts | 10 +- .../@tanstack/vue-query/asClass/types.gen.ts | 8 +- .../axios/@tanstack/vue-query.gen.ts | 9 +- .../@tanstack/vue-query/axios/client.gen.ts | 8 +- .../@tanstack/vue-query/axios/index.ts | 2 +- .../@tanstack/vue-query/axios/sdk.gen.ts | 8 +- .../@tanstack/vue-query/axios/types.gen.ts | 8 +- .../fetch/@tanstack/vue-query.gen.ts | 9 +- .../@tanstack/vue-query/fetch/client.gen.ts | 8 +- .../@tanstack/vue-query/fetch/index.ts | 2 +- .../@tanstack/vue-query/fetch/sdk.gen.ts | 8 +- .../@tanstack/vue-query/fetch/types.gen.ts | 8 +- .../name-builder/@tanstack/vue-query.gen.ts | 5 +- .../vue-query/name-builder/client.gen.ts | 8 +- .../@tanstack/vue-query/name-builder/index.ts | 2 +- .../vue-query/name-builder/sdk.gen.ts | 6 +- .../vue-query/name-builder/types.gen.ts | 8 +- .../plugins/fastify/default/fastify.gen.ts | 7 +- .../3.1.x/plugins/fastify/default/index.ts | 2 +- .../plugins/fastify/default/types.gen.ts | 8 +- .../__snapshots__/3.1.x/ref-type/index.ts | 2 +- .../__snapshots__/3.1.x/ref-type/types.gen.ts | 8 +- .../3.1.x/required-all-of-ref/index.ts | 2 +- .../3.1.x/required-all-of-ref/types.gen.ts | 8 +- .../3.1.x/required-any-of-ref/index.ts | 2 +- .../3.1.x/required-any-of-ref/types.gen.ts | 8 +- .../3.1.x/required-one-of-ref/index.ts | 2 +- .../3.1.x/required-one-of-ref/types.gen.ts | 8 +- .../__snapshots__/3.1.x/schema-const/index.ts | 2 +- .../3.1.x/schema-const/types.gen.ts | 8 +- .../3.1.x/security-api-key/client.gen.ts | 8 +- .../3.1.x/security-api-key/index.ts | 2 +- .../3.1.x/security-api-key/sdk.gen.ts | 6 +- .../3.1.x/security-api-key/types.gen.ts | 8 +- .../3.1.x/security-false/client.gen.ts | 8 +- .../3.1.x/security-false/index.ts | 2 +- .../3.1.x/security-false/sdk.gen.ts | 6 +- .../3.1.x/security-false/types.gen.ts | 8 +- .../3.1.x/security-http-bearer/client.gen.ts | 8 +- .../3.1.x/security-http-bearer/index.ts | 2 +- .../3.1.x/security-http-bearer/sdk.gen.ts | 6 +- .../3.1.x/security-http-bearer/types.gen.ts | 8 +- .../3.1.x/security-oauth2/client.gen.ts | 8 +- .../3.1.x/security-oauth2/index.ts | 2 +- .../3.1.x/security-oauth2/sdk.gen.ts | 6 +- .../3.1.x/security-oauth2/types.gen.ts | 8 +- .../security-open-id-connect/client.gen.ts | 8 +- .../3.1.x/security-open-id-connect/index.ts | 2 +- .../3.1.x/security-open-id-connect/sdk.gen.ts | 6 +- .../security-open-id-connect/types.gen.ts | 8 +- .../__snapshots__/3.1.x/servers/client.gen.ts | 8 +- .../test/__snapshots__/3.1.x/servers/index.ts | 2 +- .../__snapshots__/3.1.x/servers/types.gen.ts | 8 +- .../3.1.x/sse-angular/client.gen.ts | 8 +- .../__snapshots__/3.1.x/sse-angular/index.ts | 2 +- .../3.1.x/sse-angular/sdk.gen.ts | 6 +- .../3.1.x/sse-angular/types.gen.ts | 8 +- .../3.1.x/sse-axios/client.gen.ts | 8 +- .../__snapshots__/3.1.x/sse-axios/index.ts | 2 +- .../__snapshots__/3.1.x/sse-axios/sdk.gen.ts | 6 +- .../3.1.x/sse-axios/types.gen.ts | 8 +- .../3.1.x/sse-fetch/client.gen.ts | 8 +- .../__snapshots__/3.1.x/sse-fetch/index.ts | 2 +- .../__snapshots__/3.1.x/sse-fetch/sdk.gen.ts | 6 +- .../3.1.x/sse-fetch/types.gen.ts | 8 +- .../3.1.x/sse-next/client.gen.ts | 8 +- .../__snapshots__/3.1.x/sse-next/index.ts | 2 +- .../__snapshots__/3.1.x/sse-next/sdk.gen.ts | 6 +- .../__snapshots__/3.1.x/sse-next/types.gen.ts | 8 +- .../3.1.x/sse-nuxt/client.gen.ts | 8 +- .../__snapshots__/3.1.x/sse-nuxt/index.ts | 2 +- .../__snapshots__/3.1.x/sse-nuxt/sdk.gen.ts | 6 +- .../__snapshots__/3.1.x/sse-nuxt/types.gen.ts | 8 +- .../3.1.x/string-with-format/index.ts | 2 +- .../3.1.x/string-with-format/types.gen.ts | 8 +- .../3.1.x/transformers-all-of/client.gen.ts | 8 +- .../3.1.x/transformers-all-of/index.ts | 2 +- .../transformers-all-of/transformers.gen.ts | 26 +- .../3.1.x/transformers-all-of/types.gen.ts | 8 +- .../transformers-any-of-null/client.gen.ts | 8 +- .../3.1.x/transformers-any-of-null/index.ts | 2 +- .../transformers.gen.ts | 18 +- .../transformers-any-of-null/types.gen.ts | 8 +- .../3.1.x/transformers-array/client.gen.ts | 8 +- .../3.1.x/transformers-array/index.ts | 2 +- .../3.1.x/transformers-array/types.gen.ts | 8 +- .../3.1.x/transforms-read-write/client.gen.ts | 8 +- .../3.1.x/transforms-read-write/index.ts | 2 +- .../3.1.x/transforms-read-write/types.gen.ts | 8 +- .../__snapshots__/3.1.x/type-invalid/index.ts | 2 +- .../3.1.x/type-invalid/types.gen.ts | 4 +- .../__snapshots__/3.1.x/union-types/index.ts | 2 +- .../3.1.x/union-types/types.gen.ts | 8 +- .../__snapshots__/3.1.x/webhooks/index.ts | 2 +- .../__snapshots__/3.1.x/webhooks/types.gen.ts | 12 +- .../angular-query-experimental.gen.ts | 5 +- .../meta/@tanstack/react-query.gen.ts | 5 +- .../meta/@tanstack/solid-query.gen.ts | 5 +- .../meta/@tanstack/svelte-query.gen.ts | 5 +- .../@tanstack/meta/@tanstack/vue-query.gen.ts | 5 +- .../plugins/@tanstack/meta/client.gen.ts | 8 +- .../plugins/@tanstack/meta/index.ts | 2 +- .../plugins/@tanstack/meta/sdk.gen.ts | 6 +- .../plugins/@tanstack/meta/types.gen.ts | 8 +- .../v3-types-PascalCase/index.ts.snap | 2 +- .../v3-types-PascalCase/types.gen.ts.snap | 8 +- .../generated/v3_no_index/client.gen.ts.snap | 8 +- .../generated/v3_no_index/types.gen.ts.snap | 8 +- .../test/generated/v3_types/index.ts.snap | 2 +- .../test/generated/v3_types/types.gen.ts.snap | 8 +- .../generated/v3_types_no_tree/index.ts.snap | 2 +- .../v3_types_no_tree/types.gen.ts.snap | 8 +- .../main/test/custom/client/plugin.ts | 12 +- .../openapi-ts-tests/main/test/hey-api.ts | 13 + .../main/test/openapi-ts.config.ts | 136 +- .../specs/3.0.x/circular.yaml | 44 + .../3.0.x/mini/circular/zod.gen.ts | 49 + .../3.0.x/mini/default/zod.gen.ts | 2 +- .../3.0.x/v3/circular/zod.gen.ts | 39 + .../3.0.x/v4/circular/zod.gen.ts | 49 + .../__snapshots__/3.0.x/v4/default/zod.gen.ts | 2 +- .../3.1.x/mini/default/zod.gen.ts | 2 +- .../v3/validators-circular-ref-2/zod.gen.ts | 2 +- .../v3/validators-circular-ref/zod.gen.ts | 4 +- .../__snapshots__/3.1.x/v4/default/zod.gen.ts | 2 +- .../zod/v3/test/3.0.x.test.ts | 7 + .../3.0.x/mini/circular/zod.gen.ts | 49 + .../3.0.x/mini/default/zod.gen.ts | 2 +- .../3.0.x/v3/circular/zod.gen.ts | 39 + .../3.0.x/v4/circular/zod.gen.ts | 49 + .../__snapshots__/3.0.x/v4/default/zod.gen.ts | 2 +- .../3.1.x/mini/default/zod.gen.ts | 2 +- .../v3/validators-circular-ref-2/zod.gen.ts | 2 +- .../v3/validators-circular-ref/zod.gen.ts | 4 +- .../__snapshots__/3.1.x/v4/default/zod.gen.ts | 2 +- .../zod/v4/test/3.0.x.test.ts | 7 + packages/openapi-ts/src/config/output.ts | 56 +- .../src/generate/__tests__/class.test.ts | 10 + .../src/generate/__tests__/core.test.ts | 30 + packages/openapi-ts/src/generate/client.ts | 218 +-- packages/openapi-ts/src/generate/file.ts | 63 +- .../generate/legacy/__tests__/index.test.ts | 10 + .../generate/legacy/__tests__/output.test.ts | 9 + .../openapi-ts/src/generate/legacy/output.ts | 11 +- packages/openapi-ts/src/generate/output.ts | 73 +- packages/openapi-ts/src/generate/renderer.ts | 597 +++++--- packages/openapi-ts/src/getSpec.ts | 2 +- packages/openapi-ts/src/index.ts | 2 + packages/openapi-ts/src/ir/context.ts | 95 +- packages/openapi-ts/src/ir/types.d.ts | 75 +- packages/openapi-ts/src/ir/utils.ts | 23 +- .../src/openApi/2.0.x/parser/parameter.ts | 9 +- .../src/openApi/2.0.x/parser/schema.ts | 153 +-- .../src/openApi/3.0.x/parser/parameter.ts | 10 +- .../src/openApi/3.0.x/parser/requestBody.ts | 9 +- .../src/openApi/3.0.x/parser/schema.ts | 179 +-- .../src/openApi/3.1.x/parser/parameter.ts | 10 +- .../src/openApi/3.1.x/parser/requestBody.ts | 9 +- .../src/openApi/3.1.x/parser/schema.ts | 71 +- .../src/openApi/shared/types/schema.d.ts | 20 +- .../shared/utils/__tests__/schema.test.ts | 41 - .../src/openApi/shared/utils/schema.ts | 25 - packages/openapi-ts/src/overrides.d.ts | 9 +- .../src/plugins/@angular/common/api.ts | 10 +- .../plugins/@angular/common/httpRequests.ts | 126 +- .../plugins/@angular/common/httpResources.ts | 126 +- .../src/plugins/@angular/common/plugin.ts | 24 + .../src/plugins/@angular/common/types.d.ts | 246 ++-- .../plugins/@hey-api/client-angular/api.ts | 10 +- .../src/plugins/@hey-api/client-axios/api.ts | 10 +- .../plugins/@hey-api/client-core/client.ts | 56 +- .../plugins/@hey-api/client-core/config.ts | 1 - .../client-core/createClientConfig.ts | 46 +- .../plugins/@hey-api/client-core/plugin.ts | 12 - .../plugins/@hey-api/client-core/types.d.ts | 9 +- .../src/plugins/@hey-api/client-fetch/api.ts | 10 +- .../src/plugins/@hey-api/client-next/api.ts | 10 +- .../src/plugins/@hey-api/client-nuxt/api.ts | 10 +- .../schemas/__tests__/schemas.test.ts | 32 +- .../src/plugins/@hey-api/schemas/api.ts | 10 +- .../src/plugins/@hey-api/schemas/config.ts | 1 - .../src/plugins/@hey-api/schemas/plugin.ts | 31 +- .../src/plugins/@hey-api/schemas/types.d.ts | 79 +- .../@hey-api/sdk/__tests__/plugin.test.ts | 62 +- .../src/plugins/@hey-api/sdk/api.ts | 14 +- .../src/plugins/@hey-api/sdk/config.ts | 1 - .../src/plugins/@hey-api/sdk/operation.ts | 144 +- .../src/plugins/@hey-api/sdk/plugin.ts | 166 ++- .../src/plugins/@hey-api/sdk/typeOptions.ts | 54 +- .../src/plugins/@hey-api/sdk/types.d.ts | 620 +++++---- .../src/plugins/@hey-api/sdk/validator.ts | 2 - .../src/plugins/@hey-api/transformers/api.ts | 10 +- .../plugins/@hey-api/transformers/config.ts | 1 - .../@hey-api/transformers/expressions.ts | 3 - .../plugins/@hey-api/transformers/plugin.ts | 41 +- .../plugins/@hey-api/transformers/types.d.ts | 133 +- .../typescript/__tests__/plugin.test.ts | 17 +- .../src/plugins/@hey-api/typescript/api.ts | 21 +- .../@hey-api/typescript/clientOptions.ts | 8 +- .../src/plugins/@hey-api/typescript/config.ts | 1 - .../src/plugins/@hey-api/typescript/export.ts | 13 +- .../plugins/@hey-api/typescript/operation.ts | 67 +- .../src/plugins/@hey-api/typescript/plugin.ts | 261 ++-- .../plugins/@hey-api/typescript/types.d.ts | 874 ++++++------ .../plugins/@hey-api/typescript/webhook.ts | 64 +- .../plugins/@hey-api/typescript/webhooks.ts | 11 +- .../src/plugins/@pinia/colada/api.ts | 10 +- .../src/plugins/@pinia/colada/config.ts | 1 - .../plugins/@pinia/colada/mutationOptions.ts | 29 +- .../src/plugins/@pinia/colada/plugin.ts | 146 +- .../src/plugins/@pinia/colada/queryKey.ts | 86 +- .../src/plugins/@pinia/colada/queryOptions.ts | 55 +- .../src/plugins/@pinia/colada/state.ts | 6 - .../src/plugins/@pinia/colada/types.d.ts | 12 - .../src/plugins/@pinia/colada/useType.ts | 33 +- .../angular-query-experimental/api.ts | 10 +- .../angular-query-experimental/types.d.ts | 12 - .../query-core/infiniteQueryOptions.ts | 93 +- .../@tanstack/query-core/mutationOptions.ts | 37 +- .../plugins/@tanstack/query-core/plugin.ts | 180 +-- .../plugins/@tanstack/query-core/queryKey.ts | 76 +- .../@tanstack/query-core/queryOptions.ts | 56 +- .../plugins/@tanstack/query-core/types.d.ts | 12 - .../plugins/@tanstack/query-core/useQuery.ts | 34 +- .../plugins/@tanstack/query-core/useType.ts | 43 +- .../src/plugins/@tanstack/react-query/api.ts | 10 +- .../plugins/@tanstack/react-query/types.d.ts | 12 - .../src/plugins/@tanstack/solid-query/api.ts | 10 +- .../plugins/@tanstack/solid-query/types.d.ts | 12 - .../src/plugins/@tanstack/svelte-query/api.ts | 10 +- .../plugins/@tanstack/svelte-query/types.d.ts | 12 - .../src/plugins/@tanstack/vue-query/api.ts | 10 +- .../plugins/@tanstack/vue-query/types.d.ts | 12 - .../openapi-ts/src/plugins/fastify/api.ts | 10 +- .../openapi-ts/src/plugins/fastify/config.ts | 1 - .../openapi-ts/src/plugins/fastify/plugin.ts | 82 +- .../openapi-ts/src/plugins/fastify/types.d.ts | 25 +- .../src/plugins/shared/utils/instance.ts | 106 +- packages/openapi-ts/src/plugins/types.d.ts | 3 +- .../openapi-ts/src/plugins/valibot/api.ts | 46 +- .../openapi-ts/src/plugins/valibot/config.ts | 1 - .../src/plugins/valibot/operation.ts | 12 +- .../openapi-ts/src/plugins/valibot/plugin.ts | 85 +- .../openapi-ts/src/plugins/valibot/types.d.ts | 538 ++++---- .../openapi-ts/src/plugins/valibot/webhook.ts | 15 +- packages/openapi-ts/src/plugins/zod/api.ts | 30 +- packages/openapi-ts/src/plugins/zod/config.ts | 1 - packages/openapi-ts/src/plugins/zod/export.ts | 16 +- .../openapi-ts/src/plugins/zod/mini/plugin.ts | 144 +- .../src/plugins/zod/shared/operation.ts | 20 +- .../src/plugins/zod/shared/webhook.ts | 11 +- .../openapi-ts/src/plugins/zod/types.d.ts | 1206 ++++++++--------- .../openapi-ts/src/plugins/zod/v3/plugin.ts | 241 ++-- .../openapi-ts/src/plugins/zod/v4/plugin.ts | 145 +- packages/openapi-ts/src/tsc/module.ts | 8 +- packages/openapi-ts/src/types/config.d.ts | 14 +- packages/openapi-ts/src/types/output.d.ts | 127 +- .../src/utils/__tests__/handlebars.test.ts | 18 + .../src/utils/__tests__/parse.test.ts | 10 + 1282 files changed, 14513 insertions(+), 14471 deletions(-) create mode 100644 packages/codegen-core/src/__tests__/bimap.test.ts create mode 100644 packages/codegen-core/src/__tests__/bindings.test.ts rename packages/codegen-core/src/__tests__/{ => data}/file.ts (100%) create mode 100644 packages/codegen-core/src/__tests__/exports.test.ts delete mode 100644 packages/codegen-core/src/__tests__/file.test.ts create mode 100644 packages/codegen-core/src/__tests__/files.test.ts create mode 100644 packages/codegen-core/src/__tests__/symbols.test.ts rename packages/codegen-core/src/{imports => bindings}/types.d.ts (62%) create mode 100644 packages/codegen-core/src/bindings/utils.ts create mode 100644 packages/codegen-core/src/extensions/types.d.ts delete mode 100644 packages/codegen-core/src/files/file.ts create mode 100644 packages/codegen-core/src/files/registry.ts delete mode 100644 packages/codegen-core/src/meta/types.d.ts create mode 100644 packages/codegen-core/src/renderer/types.d.ts rename packages/codegen-core/src/{renderers/renderer.ts => renderer/utils.ts} (96%) delete mode 100644 packages/codegen-core/src/renderers/types.d.ts create mode 100644 packages/codegen-core/src/selectors/types.d.ts create mode 100644 packages/codegen-core/src/symbols/registry.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/{common/http/requests.gen.ts => common.gen.ts} (51%) delete 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__/3.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts delete 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/@angular/common.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/{my-client/base-url-false/client.gen.ts => client-custom/base-url-false/custom-client.gen.ts} (50%) delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/client.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/{bundle/client.gen.ts => base-url-number/custom-client.gen.ts} (53%) delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/client.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/{my-client/base-url-number/client.gen.ts => client-custom/base-url-strict/custom-client.gen.ts} (53%) rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/{my-client/base-url-string/client.gen.ts => client-custom/base-url-string/custom-client.gen.ts} (53%) create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/custom-client.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/client.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/{my-client/base-url-strict/client.gen.ts => client-custom/default/custom-client.gen.ts} (53%) delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/client.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/{my-client/bundle/client.gen.ts => client-custom/sdk-client-optional/custom-client.gen.ts} (53%) delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/custom-client.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/{client-custom/base-url-false/client.gen.ts => my-client/base-url-false/custom.gen.ts} (50%) create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/custom.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/custom.gen.ts rename packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/{client-custom/base-url-string/client.gen.ts => my-client/base-url-string/custom.gen.ts} (52%) create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/custom.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/custom.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/custom.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/custom.gen.ts create mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts delete 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/@angular/common.gen.ts delete mode 100644 packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts delete 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/hey-api.ts create mode 100644 packages/openapi-ts-tests/specs/3.0.x/circular.yaml create mode 100644 packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/circular/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/circular/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/circular/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/circular/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/circular/zod.gen.ts create mode 100644 packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/circular/zod.gen.ts delete mode 100644 packages/openapi-ts/src/openApi/shared/utils/__tests__/schema.test.ts delete mode 100644 packages/openapi-ts/src/plugins/@pinia/colada/state.ts diff --git a/packages/codegen-core/src/__tests__/bimap.test.ts b/packages/codegen-core/src/__tests__/bimap.test.ts new file mode 100644 index 000000000..b28fe2665 --- /dev/null +++ b/packages/codegen-core/src/__tests__/bimap.test.ts @@ -0,0 +1,66 @@ +import { describe, expect, it } from 'vitest'; + +import { BiMap } from '../bimap/bimap'; + +describe('BiMap', () => { + it('covers the full public interface', () => { + const bimap = new BiMap(); + // set and get + expect(bimap.set(1, 'a')).toBe(bimap); + expect(bimap.set(2, 'b')).toBe(bimap); + // get, getKey + expect(bimap.get(1)).toBe('a'); + expect(bimap.get(2)).toBe('b'); + expect(bimap.getKey('a')).toBe(1); + expect(bimap.getKey('b')).toBe(2); + // hasKey, hasValue + expect(bimap.hasKey(1)).toBe(true); + expect(bimap.hasKey(2)).toBe(true); + expect(bimap.hasKey(3)).toBe(false); + expect(bimap.hasValue('a')).toBe(true); + expect(bimap.hasValue('b')).toBe(true); + expect(bimap.hasValue('c')).toBe(false); + // keys, values, entries + expect(Array.from(bimap.keys())).toEqual([1, 2]); + expect(Array.from(bimap.values())).toEqual(['a', 'b']); + expect(Array.from(bimap.entries())).toEqual([ + [1, 'a'], + [2, 'b'], + ]); + // Symbol.iterator + expect(Array.from(bimap)).toEqual([ + [1, 'a'], + [2, 'b'], + ]); + // size + expect(bimap.size).toBe(2); + // delete by key + expect(bimap.delete(1)).toBe(true); + expect(bimap.hasKey(1)).toBe(false); + expect(bimap.hasValue('a')).toBe(false); + // delete by value + expect(bimap.deleteValue('b')).toBe(true); + expect(bimap.hasKey(2)).toBe(false); + expect(bimap.hasValue('b')).toBe(false); + // After all deletes + expect(bimap.size).toBe(0); + // Setting again to check overwrite + bimap.set(1, 'x'); + bimap.set(2, 'y'); + expect(bimap.get(1)).toBe('x'); + expect(bimap.get(2)).toBe('y'); + // Overwrite value for existing key + bimap.set(1, 'z'); + expect(bimap.get(1)).toBe('z'); + expect(bimap.getKey('z')).toBe(1); + // Overwrite key for existing value + bimap.set(3, 'z'); + expect(bimap.getKey('z')).toBe(3); + expect(bimap.get(1)).toBeUndefined(); + // Iteration after overwrite + expect(Array.from(bimap)).toEqual([ + [2, 'y'], + [3, 'z'], + ]); + }); +}); diff --git a/packages/codegen-core/src/__tests__/bindings.test.ts b/packages/codegen-core/src/__tests__/bindings.test.ts new file mode 100644 index 000000000..7debb873e --- /dev/null +++ b/packages/codegen-core/src/__tests__/bindings.test.ts @@ -0,0 +1,226 @@ +import { describe, expect, it } from 'vitest'; + +import type { IBiMap } from '../bimap/types'; +import type { IBinding } from '../bindings/types'; +import { createBinding, mergeBindings } from '../bindings/utils'; +import type { ISymbolMeta } from '../extensions/types'; +import type { IFileOut } from '../files/types'; +import type { ISymbolOut } from '../symbols/types'; + +function makeBiMap(entries: [number, string][] = []): IBiMap { + const map = new Map(entries); + const reverse = new Map(entries.map(([k, v]) => [v, k])); + const bimap: IBiMap = { + delete: (key: number) => { + const value = map.get(key); + map.delete(key); + if (value) reverse.delete(value); + return true; + }, + deleteValue: (value: string) => { + const key = reverse.get(value); + reverse.delete(value); + if (key) map.delete(key); + return true; + }, + entries: () => map.entries(), + get: (key: number) => map.get(key), + getKey: (value: string) => reverse.get(value), + hasKey: (key: number) => map.has(key), + hasValue: (value: string) => reverse.has(value), + keys() { + return map.keys(); + }, + set: (key: number, value: string): IBiMap => { + map.set(key, value); + reverse.set(value, key); + return bimap; + }, + size: 0, + values() { + return map.values(); + }, + [Symbol.iterator]() { + return map[Symbol.iterator](); + }, + }; + return bimap; +} + +const makeFile = ( + resolvedNames: IBiMap = makeBiMap(), + id: number = 1, +): IFileOut => ({ + extension: 'ts', + id, + name: '', + path: '', + resolvedNames, + selector: [], + symbols: { body: [], exports: [], imports: [] }, +}); + +const makeSymbol = ( + id: number, + placeholder: string, + meta: ISymbolMeta = {}, + name?: string, +): ISymbolOut => ({ + exportFrom: [], + id, + meta, + name, + placeholder, +}); + +describe('createBinding', () => { + it('creates a named binding by default', () => { + const file = makeFile(makeBiMap([[1, 'Foo']])); + const symbol = makeSymbol( + 1, + 'Foo', + { importKind: 'named', kind: 'value' }, + 'Foo', + ); + const symbolFile = makeFile(makeBiMap([[1, 'Foo']])); + const binding = createBinding({ + file, + modulePath: './foo', + symbol, + symbolFile, + }); + expect(binding).toEqual({ + aliases: {}, + from: './foo', + names: ['Foo'], + typeNames: [], + }); + }); + + it('creates a default binding', () => { + const file = makeFile(); + const symbol = makeSymbol( + 2, + 'Bar', + { importKind: 'default', kind: 'value' }, + 'Bar', + ); + const symbolFile = makeFile(); + const binding = createBinding({ + file, + modulePath: './bar', + symbol, + symbolFile, + }); + expect(binding).toEqual({ + aliases: {}, + defaultBinding: 'Bar', + from: './bar', + names: [], + typeDefaultBinding: undefined, + typeNames: [], + }); + }); + + it('creates a namespace binding', () => { + const file = makeFile(); + const symbol = makeSymbol( + 3, + 'Baz', + { importKind: 'namespace', kind: 'value' }, + 'Baz', + ); + const symbolFile = makeFile(); + const binding = createBinding({ + file, + modulePath: './baz', + symbol, + symbolFile, + }); + expect(binding).toEqual({ + aliases: {}, + from: './baz', + names: [], + namespaceBinding: 'Baz', + typeNames: [], + typeNamespaceBinding: undefined, + }); + }); + + it('creates type names for type symbols', () => { + const file = makeFile(makeBiMap([[4, 'Qux']])); + const symbol = makeSymbol( + 4, + 'Qux', + { importKind: 'named', kind: 'type' }, + 'Qux', + ); + const symbolFile = makeFile(makeBiMap([[4, 'Qux']])); + const binding = createBinding({ + file, + modulePath: './qux', + symbol, + symbolFile, + }); + expect(binding).toEqual({ + aliases: {}, + from: './qux', + names: ['Qux'], + typeNames: ['Qux'], + }); + }); +}); + +describe('mergeBindings', () => { + it('merges aliases, names, and typeNames', () => { + const target: IBinding = { + aliases: { Foo: 'Bar' }, + from: './foo', + names: ['Foo'], + typeNames: ['Foo'], + }; + const source: IBinding = { + aliases: { Baz: 'Qux' }, + from: './foo', + names: ['Baz'], + typeNames: ['Baz'], + }; + mergeBindings(target, source); + expect(target).toEqual({ + aliases: { Baz: 'Qux', Foo: 'Bar' }, + from: './foo', + names: ['Foo', 'Baz'], + typeNames: ['Foo', 'Baz'], + }); + }); + + it('merges default and namespace bindings', () => { + const target: IBinding = { + aliases: {}, + from: './foo', + names: [], + typeNames: [], + }; + const source: IBinding = { + aliases: {}, + defaultBinding: 'Default', + from: './foo', + names: [], + namespaceBinding: 'NS', + typeDefaultBinding: true, + typeNames: [], + typeNamespaceBinding: true, + }; + mergeBindings(target, source); + expect(target).toEqual({ + aliases: {}, + defaultBinding: 'Default', + from: './foo', + names: [], + namespaceBinding: 'NS', + typeDefaultBinding: true, + typeNames: [], + typeNamespaceBinding: true, + }); + }); +}); diff --git a/packages/codegen-core/src/__tests__/file.ts b/packages/codegen-core/src/__tests__/data/file.ts similarity index 100% rename from packages/codegen-core/src/__tests__/file.ts rename to packages/codegen-core/src/__tests__/data/file.ts diff --git a/packages/codegen-core/src/__tests__/exports.test.ts b/packages/codegen-core/src/__tests__/exports.test.ts new file mode 100644 index 000000000..36a664ada --- /dev/null +++ b/packages/codegen-core/src/__tests__/exports.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, it } from 'vitest'; + +import * as index from '../index'; + +const constExports = ['createBinding', 'mergeBindings', 'Project', 'renderIds']; + +// Type-level test: will fail to compile if any type export is missing or renamed +export type _TypeExports = [ + index.BiMap, + index.Binding, + index.ProjectRenderMeta, + index.SymbolMeta, + index.File, + index.FileIn, + index.Output, + index.IProject, + index.Renderer, + index.Selector, + index.Symbol, + index.SymbolIn, +]; + +describe('index exports', () => { + it('should export all expected symbols', () => { + for (const key of constExports) { + expect(index).toHaveProperty(key); + } + }); +}); diff --git a/packages/codegen-core/src/__tests__/file.test.ts b/packages/codegen-core/src/__tests__/file.test.ts deleted file mode 100644 index 8ad3adb67..000000000 --- a/packages/codegen-core/src/__tests__/file.test.ts +++ /dev/null @@ -1,232 +0,0 @@ -import { beforeEach, describe, expect, it } from 'vitest'; - -import { CodegenFile } from '../files/file'; -import type { ICodegenImport } from '../imports/types'; -import { CodegenProject } from '../project/project'; -import type { ICodegenSymbolIn } from '../symbols/types'; - -describe('CodegenFile', () => { - let file: CodegenFile; - let project: CodegenProject; - - beforeEach(() => { - project = new CodegenProject(); - file = new CodegenFile('a.ts', project); - }); - - it('initializes with empty imports and symbols', () => { - expect(file.imports).toEqual([]); - expect(file.symbols).toEqual([]); - }); - - it('adds exports', () => { - const exp1: ICodegenImport = { from: 'a' }; - const exp2: ICodegenImport = { from: 'b' }; - - file.addExport(exp1); - file.addExport(exp2); - - expect(file.exports.length).toBe(2); - expect(file.exports[0]).not.toBe(exp1); - expect(file.exports[0]).toEqual(exp1); - expect(file.exports[1]).not.toBe(exp2); - expect(file.exports[1]).toEqual(exp2); - }); - - it('merges duplicate exports', () => { - const exp1: ICodegenImport = { - aliases: { - A: 'AliasA', - }, - from: 'a', - names: ['A'], - typeNames: ['AType'], - }; - const exp2: ICodegenImport = { - aliases: { - B: 'AliasB', - }, - from: 'a', - names: ['B'], - typeNames: ['AType'], - }; - - file.addExport(exp1); - file.addExport(exp2); - - expect(file.exports.length).toBe(1); - expect(file.exports[0]).toEqual({ - aliases: { - A: 'AliasA', - B: 'AliasB', - }, - from: 'a', - names: ['A', 'AType', 'B'], - typeNames: ['AType'], - }); - }); - - it('adds imports', () => { - const imp1: ICodegenImport = { from: 'a' }; - const imp2: ICodegenImport = { from: 'b' }; - - file.addImport(imp1); - file.addImport(imp2); - - expect(file.imports.length).toBe(2); - expect(file.imports[0]).not.toBe(imp1); - expect(file.imports[0]).toEqual(imp1); - expect(file.imports[1]).not.toBe(imp2); - expect(file.imports[1]).toEqual(imp2); - }); - - it('merges duplicate imports', () => { - const imp1: ICodegenImport = { - aliases: { - A: 'AliasA', - }, - from: 'a', - names: ['A'], - typeNames: ['AType'], - }; - const imp2: ICodegenImport = { - aliases: { - B: 'AliasB', - }, - from: 'a', - names: ['B'], - typeNames: ['AType'], - }; - - file.addImport(imp1); - file.addImport(imp2); - - expect(file.imports.length).toBe(1); - expect(file.imports[0]).toEqual({ - aliases: { - A: 'AliasA', - B: 'AliasB', - }, - from: 'a', - names: ['A', 'AType', 'B'], - typeNames: ['AType'], - }); - }); - - it('adds symbols', () => { - 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]).toMatchObject(sym1); - expect(file.symbols[1]).not.toBeUndefined(); - expect(file.symbols[1]).not.toBe(sym2); - expect(file.symbols[1]).toMatchObject(sym2); - }); - - it('updates symbols', () => { - const sym1: ICodegenSymbolIn = { - headless: true, - name: 'a', - value: 1, - }; - const inserted = file.addSymbol(sym1); - expect(file.symbols.length).toBe(0); - - const sym2: ICodegenSymbolIn = { - headless: false, - name: 'b', - value: 'foo', - }; - inserted.update(sym2); - - expect(file.symbols.length).toBe(1); - expect(file.symbols[0]).toMatchObject({ - name: 'b', - value: 'foo', - }); - }); - - it('getAllSymbols returns declared symbols plus imports and exports with alias applied', () => { - file.addSymbol({ name: 'Local', value: {} }); - file.addImport({ - aliases: { A: 'AliasA' }, - from: 'lib', - names: ['A', 'B'], - }); - file.addExport({ - aliases: { C: 'AliasC' }, - from: 'lib', - names: ['C', 'D'], - }); - - const all = file.getAllSymbols().map((s) => s.name); - expect(all).toEqual(['Local', 'AliasA', 'B', 'AliasC', 'D']); - }); - - it('hasSymbol returns true if symbol exists', () => { - 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', () => { - expect(file.exports).toEqual([]); - expect(file.imports).toEqual([]); - expect(file.symbols).toEqual([]); - - const imp = { from: 'lib', names: ['X'] }; - const symbol = { name: 'Sym', value: {} }; - - file.addExport(imp); - expect(file.exports).toEqual([imp]); - - file.addImport(imp); - expect(file.imports).toEqual([imp]); - - file.addSymbol(symbol); - expect(file.symbols.length).toBe(1); - expect(file.symbols[0]).toMatchObject(symbol); - }); - - it('returns relative path to another files', () => { - const path1 = file.relativePathToFile({ path: 'b' }); - expect(path1).toBe('./b'); - - const path2 = file.relativePathToFile({ path: './b' }); - expect(path2).toBe('./b'); - - const path3 = file.relativePathToFile({ path: '../b' }); - expect(path3).toBe('../b'); - - const path4 = file.relativePathToFile({ path: '../../b' }); - expect(path4).toBe('../../b'); - - const path5 = file.relativePathToFile({ path: 'b/c' }); - expect(path5).toBe('./b/c'); - }); - - it('returns relative path to this file', () => { - const path1 = file.relativePathFromFile({ path: 'b' }); - expect(path1).toBe('./a.ts'); - - const path2 = file.relativePathFromFile({ path: './b' }); - expect(path2).toBe('./a.ts'); - - const path3 = file.relativePathFromFile({ path: '../b' }); - expect(path3).toBe('./codegen-core/a.ts'); - - const path4 = file.relativePathFromFile({ path: '../../b' }); - expect(path4).toBe('./packages/codegen-core/a.ts'); - - const path5 = file.relativePathFromFile({ path: 'b/c' }); - expect(path5).toBe('../a.ts'); - }); -}); diff --git a/packages/codegen-core/src/__tests__/files.test.ts b/packages/codegen-core/src/__tests__/files.test.ts new file mode 100644 index 000000000..a90011a23 --- /dev/null +++ b/packages/codegen-core/src/__tests__/files.test.ts @@ -0,0 +1,94 @@ +import { describe, expect, it } from 'vitest'; + +import { FileRegistry } from '../files/registry'; + +describe('FileRegistry', () => { + it('covers the full public interface', () => { + const registry = new FileRegistry(); + // id property increments + const id1 = registry.id; + const id2 = registry.id; + expect(typeof id1).toBe('number'); + expect(id2).toBe(id1 + 1); + + // Register a file with selector + const file1 = registry.register({ name: 'Foo', selector: ['foo'] }); + expect(file1).toEqual({ + extension: undefined, + external: undefined, + id: expect.any(Number), + name: 'Foo', + path: undefined, + resolvedNames: expect.any(Object), + selector: ['foo'], + symbols: { body: [], exports: [], imports: [] }, + }); + + // get by id and selector + expect(registry.get(file1.id)).toEqual(file1); + expect(registry.get(['foo'])).toEqual(file1); + + // Registering again with same selector returns same file + const file1b = registry.register({ selector: ['foo'] }); + expect(file1b).toEqual(file1); + + // Registering with id returns same file + const file1c = registry.register({ id: file1.id }); + expect(file1c).toEqual(file1); + + // Reference by id returns same file + const ref1 = registry.reference(file1.id); + expect(ref1).toEqual(file1); + + // Reference by selector returns same file + const ref1b = registry.reference(['foo']); + expect(ref1b).toEqual(file1); + + // Register a new file with a different selector + const file2 = registry.register({ + name: 'Bar', + path: '/bar', + selector: ['bar'], + }); + expect(file2).toEqual({ + extension: undefined, + external: undefined, + id: expect.any(Number), + name: 'Bar', + path: '/bar', + resolvedNames: expect.any(Object), + selector: ['bar'], + symbols: { body: [], exports: [], imports: [] }, + }); + + // Registered files are yielded in order + const registered = Array.from(registry.registered()); + expect(registered).toEqual([ + expect.objectContaining({ selector: ['foo'] }), + expect.objectContaining({ selector: ['bar'] }), + ]); + + // Referenced files are yielded in order + // Only files referenced but not registered are included + // Reference a new file (not registered) + const file3 = registry.reference(['baz']); + const referenced = Array.from(registry.referenced()); + expect(referenced).toContainEqual(file3); + // Once registered, file1 is not in referenced set + expect(referenced).not.toContainEqual(file1); + }); + + it('throws on invalid register or reference', () => { + const registry = new FileRegistry(); + // Register with id that does not exist + expect(() => registry.register({ id: 9999 })).toThrow( + 'File with ID 9999 not found. To register a new file, leave the ID undefined.', + ); + // Register with selector that maps to missing id + // Simulate by manually setting selectorToId + registry['selectorToId'].set(JSON.stringify(['missing']), 42); + expect(() => registry.register({ selector: ['missing'] })).toThrow( + 'File with ID 42 not found. The selector ["missing"] matched an ID, but there was no result. This is likely an issue with the application logic.', + ); + }); +}); diff --git a/packages/codegen-core/src/__tests__/project.test.ts b/packages/codegen-core/src/__tests__/project.test.ts index 3d1e6d9e2..d7f2a70a6 100644 --- a/packages/codegen-core/src/__tests__/project.test.ts +++ b/packages/codegen-core/src/__tests__/project.test.ts @@ -1,135 +1,90 @@ -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'; - -describe('CodegenProject', () => { - let project: CodegenProject; - - beforeEach(() => { - project = new CodegenProject(); - }); - - it('adds new files and preserves order', () => { - const file1 = project.createFile('a.ts'); - const file2 = project.createFile('b.ts'); - - expect(project.files).toEqual([file1, file2]); - }); - - it('replaces existing file but keeps order', () => { - project.createFile('a.ts'); - project.createFile('b.ts'); - project.createFile('c.ts'); - const newFile2 = project.createFile('b.ts'); - - expect(project.files.length).toBe(3); - expect(project.files[1]).toBe(newFile2); - expect(project.getFileByPath('b.ts')).toBe(newFile2); - }); - - it('addExport creates file if missing and adds export', () => { - const imp = { from: 'lib', names: ['Foo'] }; - - project.addExport('a.ts', imp); - - const file = project.getFileByPath('a.ts')!; - expect(file).toBeDefined(); - expect(file.exports.length).toBe(1); - expect(file.exports[0]).toEqual(imp); - }); - - it('addImport creates file if missing and adds import', () => { - const imp = { from: 'lib', names: ['Foo'] }; - - project.addImport('a.ts', imp); - - const file = project.getFileByPath('a.ts')!; - expect(file).toBeDefined(); - expect(file.imports.length).toBe(1); - expect(file.imports[0]).toEqual(imp); - }); - - it('addSymbol creates file if missing and adds symbol', () => { - const symbol = { name: 'MySymbol', value: {} }; - - project.addSymbol('a.ts', symbol); - - const file = project.getFileByPath('a.ts')!; - expect(file).toBeDefined(); - expect(file.symbols.length).toBe(1); - expect(file.symbols[0]).toMatchObject(symbol); - }); - - it('getAllSymbols returns all symbols from all files', () => { - const file1 = project.createFile('a.ts'); - const file2 = project.createFile('b.ts'); - - file1.addSymbol({ name: 'A', value: {} }); - file2.addSymbol({ name: 'B', value: {} }); - - const symbols = project.getAllSymbols().map((s) => s.name); - expect(symbols).toEqual(['A', 'B']); - }); - - it('getFileByPath returns undefined for unknown path', () => { - expect(project.getFileByPath('unknown.ts')).toBeUndefined(); - }); - - it('files getter returns a copy of the files array', () => { - const file = project.createFile('a.ts'); - - const files = project.files; - expect(files).toEqual([file]); - - // @ts-expect-error - // mutate returned array should not affect internal state - 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'; - // 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}`; - } - // 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 }; - project.createFile('a.ts', { renderer }); - project.createFile('b.ts', { renderer }); - - const outputs = project.render(meta); +import { describe, expect, it } from 'vitest'; + +import type { IFileOut } from '../files/types'; +import { Project } from '../project/project'; +import type { IRenderer } from '../renderer/types'; + +describe('Project', () => { + it('covers the full public interface', () => { + const renderer: IRenderer = { + renderFile: (content: string) => `RENDERED:${content}`, + renderSymbols: (file: IFileOut) => `SYMBOLS:${file.name}`, + }; + const project = new Project({ + defaultFileName: 'main', + renderers: { '.ts': renderer }, + root: '/root', + }); + + // Registries are defined + expect(project.files).toBeDefined(); + expect(project.symbols).toBeDefined(); + + // Add a symbol and render output + const symbol = project.symbols.register({ + getFilePath: () => 'foo', + placeholder: 'Foo', + selector: ['foo'], + }); + // Add a renderer for .ts files + // Simulate a file with .ts extension + project.files.register({ + extension: '.ts', + name: 'foo', + path: '/root/foo.ts', + selector: ['foo'], + }); + // Render output + const outputs = project.render(); + expect(Array.isArray(outputs)).toBe(true); + expect(outputs.length).toBe(1); expect(outputs).toEqual([ - { content: 'content a.ts', meta: { renderer: 'foo' }, path: 'a.ts' }, - { content: 'content b.ts', meta: { renderer: 'foo' }, path: 'b.ts' }, + { + content: 'RENDERED:SYMBOLS:foo', + path: '/root/foo.ts', + }, ]); + + // symbolIdToFiles returns correct files + const filesForSymbol = project.symbolIdToFiles(symbol.id); + expect(filesForSymbol.length).toBeGreaterThan(0); + expect(filesForSymbol[0]?.name).toBe('foo'); }); - it('createFile adds and returns a new file with optional meta', () => { - const file = project.createFile('a.ts', { extension: '.ts' }); + it('skips files with no renderer or external', () => { + const project = new Project({ + defaultFileName: 'main', + renderers: {}, + root: '/root', + }); + // Register a file with no extension + project.files.register({ name: 'noext', selector: ['noext'] }); + // Register an external file + project.files.register({ external: true, name: 'ext', selector: ['ext'] }); + // Should not throw, but output should be empty + const outputs = project.render(); + expect(outputs).toEqual([]); + }); - expect(file.path).toBe('a.ts'); - expect(file.meta).toEqual({ extension: '.ts' }); - expect(project.getFileByPath('a.ts')).toBe(file); - expect(project.files).toEqual([file]); + it('respects fileName override', () => { + const renderer: IRenderer = { + renderFile: (content: string) => content, + renderSymbols: (file: IFileOut) => `SYMBOLS:${file.name}`, + }; + const project = new Project({ + defaultFileName: 'main', + fileName: (name) => `X_${name}`, + renderers: { '.ts': renderer }, + root: '/root', + }); + // Register a symbol with selector + project.symbols.register({ + getFilePath: () => 'bar', + placeholder: 'Bar', + selector: ['bar'], + }); + // Render output (should use fileName override) + const outputs = project.render(); + expect(outputs[0]?.path).toContain('X_bar'); }); }); diff --git a/packages/codegen-core/src/__tests__/renderer.test.ts b/packages/codegen-core/src/__tests__/renderer.test.ts index efaf438a6..48559e13b 100644 --- a/packages/codegen-core/src/__tests__/renderer.test.ts +++ b/packages/codegen-core/src/__tests__/renderer.test.ts @@ -3,11 +3,11 @@ import path from 'node:path'; import { describe, expect, it } from 'vitest'; -import { replaceWrappedIds } from '../renderers/renderer'; +import { renderIds, wrapId } from '../renderer/utils'; -describe('replaceWrappedIds', () => { +describe('renderIds', () => { it('replaces ids with names', () => { - const source = fs.readFileSync(path.resolve(__dirname, 'file.ts'), { + const source = fs.readFileSync(path.resolve(__dirname, 'data', 'file.ts'), { encoding: 'utf8', }); @@ -19,7 +19,7 @@ describe('replaceWrappedIds', () => { 5: 'Foo', }; - const replaced = replaceWrappedIds(source, (id) => substitutions[id]); + const replaced = renderIds(source, (id) => substitutions[id]); expect(replaced).toEqual(`/* @ts-nocheck */ @@ -38,3 +38,12 @@ export class Foo { `); }); }); + +describe('wrapId', () => { + it('wraps id in the expected format', () => { + expect(wrapId(String(42))).toBe('_heyapi_42_'); + expect(wrapId(String(0))).toBe('_heyapi_0_'); + expect(wrapId(String(123456))).toBe('_heyapi_123456_'); + expect(wrapId('foo')).toBe('_heyapi_foo_'); + }); +}); diff --git a/packages/codegen-core/src/__tests__/symbols.test.ts b/packages/codegen-core/src/__tests__/symbols.test.ts new file mode 100644 index 000000000..4d905797f --- /dev/null +++ b/packages/codegen-core/src/__tests__/symbols.test.ts @@ -0,0 +1,93 @@ +import { describe, expect, it } from 'vitest'; + +import { SymbolRegistry } from '../symbols/registry'; + +describe('SymbolRegistry', () => { + it('covers the full public interface', () => { + const registry = new SymbolRegistry(); + // id property increments + const id1 = registry.id; + const id2 = registry.id; + expect(typeof id1).toBe('number'); + expect(id2).toBe(id1 + 1); + + // Register a symbol with selector + const symbol1 = registry.register({ + placeholder: 'Foo', + selector: ['foo'], + }); + expect(symbol1).toEqual({ + exportFrom: [], + id: expect.any(Number), + placeholder: 'Foo', + selector: ['foo'], + }); + + // get by id and selector + expect(registry.get(symbol1.id)).toEqual(symbol1); + expect(registry.get(['foo'])).toEqual(symbol1); + + // Registering again with same selector returns same symbol + const symbol1b = registry.register({ selector: ['foo'] }); + expect(symbol1b).toEqual(symbol1); + + // Registering with id returns same symbol + const symbol1c = registry.register({ id: symbol1.id }); + expect(symbol1c).toEqual(symbol1); + + // Reference by id returns same symbol + const ref1 = registry.reference(symbol1.id); + expect(ref1).toEqual(symbol1); + + // Reference by selector returns same symbol + const ref1b = registry.reference(['foo']); + expect(ref1b).toEqual(symbol1); + + // Register a new symbol with a different selector + const symbol2 = registry.register({ + exportFrom: ['x'], + placeholder: 'Bar', + selector: ['bar'], + }); + expect(symbol2).toEqual({ + exportFrom: ['x'], + id: expect.any(Number), + placeholder: 'Bar', + selector: ['bar'], + }); + + // Registering with same selector and extra exportFrom merges exportFrom + const symbol2b = registry.register({ + exportFrom: ['y'], + selector: ['bar'], + }); + expect(symbol2b.exportFrom).toEqual(['x', 'y']); + + // Registered symbols are yielded in order + const registered = Array.from(registry.registered()); + expect(registered).toEqual([ + expect.objectContaining({ selector: ['foo'] }), + expect.objectContaining({ selector: ['bar'] }), + ]); + + // setValue, getValue, hasValue + expect(registry.hasValue(symbol1.id)).toBe(false); + registry.setValue(symbol1.id, 42); + expect(registry.hasValue(symbol1.id)).toBe(true); + expect(registry.getValue(symbol1.id)).toBe(42); + }); + + it('throws on invalid register or reference', () => { + const registry = new SymbolRegistry(); + // Register with id that does not exist + expect(() => registry.register({ id: 9999 })).toThrow( + 'Symbol with ID 9999 not found. To register a new symbol, leave the ID undefined.', + ); + // Register with selector that maps to missing id + // Simulate by manually setting selectorToId + registry['selectorToId'].set(JSON.stringify(['missing']), 42); + expect(() => registry.register({ selector: ['missing'] })).toThrow( + 'Symbol with ID 42 not found. The selector ["missing"] matched an ID, but there was no result. This is likely an issue with the application logic.', + ); + }); +}); diff --git a/packages/codegen-core/src/bimap/bimap.ts b/packages/codegen-core/src/bimap/bimap.ts index c2cc9ef8f..93f21afb9 100644 --- a/packages/codegen-core/src/bimap/bimap.ts +++ b/packages/codegen-core/src/bimap/bimap.ts @@ -1,6 +1,6 @@ -import type { ICodegenBiMap } from './types'; +import type { IBiMap } from './types'; -export class BiMap implements ICodegenBiMap { +export class BiMap implements IBiMap { private map = new Map(); private reverse = new Map(); @@ -45,6 +45,14 @@ export class BiMap implements ICodegenBiMap { } set(key: Key, value: Value): this { + const oldValue = this.map.get(key); + if (oldValue !== undefined && oldValue !== value) { + this.reverse.delete(oldValue); + } + const oldKey = this.reverse.get(value); + if (oldKey !== undefined && oldKey !== key) { + this.map.delete(oldKey); + } this.map.set(key, value); this.reverse.set(value, key); return this; diff --git a/packages/codegen-core/src/bimap/types.d.ts b/packages/codegen-core/src/bimap/types.d.ts index 610d6b2f3..c7b81aea3 100644 --- a/packages/codegen-core/src/bimap/types.d.ts +++ b/packages/codegen-core/src/bimap/types.d.ts @@ -6,7 +6,7 @@ * @template Key Type of the map keys * @template Value Type of the map values */ -export interface ICodegenBiMap { +export interface IBiMap { /** * Deletes a key and its associated value from the map. * diff --git a/packages/codegen-core/src/imports/types.d.ts b/packages/codegen-core/src/bindings/types.d.ts similarity index 62% rename from packages/codegen-core/src/imports/types.d.ts rename to packages/codegen-core/src/bindings/types.d.ts index e0c049834..2510411f9 100644 --- a/packages/codegen-core/src/imports/types.d.ts +++ b/packages/codegen-core/src/bindings/types.d.ts @@ -1,8 +1,6 @@ -import type { ICodegenFile } from '../files/types'; - -export interface ICodegenImport { +export interface IBinding { /** - * Optional aliasing map for imported symbols. + * Optional aliasing map for named symbols. * * Keys must be a subset of `names`, values are aliases. * @@ -10,25 +8,22 @@ export interface ICodegenImport { */ aliases?: Record; /** - * Name of the default import, if any. + * Name of the default binding, if any. * * @example "React" */ - defaultImport?: string; + defaultBinding?: string; /** * Source file or external module from which symbols are imported. * - * For internal files, this should be a ICodegenFile instance to enable - * dynamic path computation. For external or system modules, use a string. - * * @example "./models/user" * @example "node:path" */ - from: ICodegenFile | string; + from: string; /** * Names of the symbols imported from the source. * - * Must be non-empty unless `isNamespaceImport` is true. + * Must be non-empty unless `namespaceBinding` is true. * All imported names, regardless of whether they are used as types or values. * * @example ["User", "UserDTO"] @@ -41,13 +36,13 @@ export interface ICodegenImport { * @example "utils" * @example true */ - namespaceImport?: boolean | string; + namespaceBinding?: boolean | string; /** - * Whether the default import is type-only. + * Whether the default binding is type-only. * * @example true */ - typeDefaultImport?: boolean; + typeDefaultBinding?: boolean; /** * Subset of `names` that are imported using the `type` modifier. * These symbols will be emitted as type-only imports in TypeScript. @@ -56,9 +51,9 @@ export interface ICodegenImport { */ typeNames?: ReadonlyArray; /** - * Whether the namespace import is type-only. + * Whether the namespace binding is type-only. * * @example true */ - typeNamespaceImport?: boolean; + typeNamespaceBinding?: boolean; } diff --git a/packages/codegen-core/src/bindings/utils.ts b/packages/codegen-core/src/bindings/utils.ts new file mode 100644 index 000000000..84cc84b99 --- /dev/null +++ b/packages/codegen-core/src/bindings/utils.ts @@ -0,0 +1,91 @@ +import type { IFileOut } from '../files/types'; +import type { ISymbolOut } from '../symbols/types'; +import type { IBinding } from './types'; + +export const createBinding = ({ + file, + modulePath, + symbol, + symbolFile, +}: { + file: IFileOut; + modulePath: string; + symbol: ISymbolOut; + symbolFile: IFileOut; +}): IBinding => { + const names: Array = []; + const typeNames: Array = []; + const binding: IBinding & Pick, 'aliases' | 'from'> = { + aliases: {}, + from: modulePath, + }; + if (symbol.meta?.importKind) { + if (symbol.meta.importKind === 'default') { + binding.defaultBinding = symbol.placeholder; + if (symbol.meta.kind === 'type') { + binding.typeDefaultBinding = true; + } + } else if (symbol.meta.importKind === 'namespace') { + binding.namespaceBinding = symbol.placeholder; + if (symbol.meta.kind === 'type') { + binding.typeNamespaceBinding = true; + } + } + } + // default to named binding + if ( + symbol.meta?.importKind === 'named' || + (!names.length && !binding.defaultBinding && !binding.namespaceBinding) + ) { + let name = symbol.placeholder; + const fileResolvedName = file.resolvedNames.get(symbol.id); + if (fileResolvedName) { + const symbolFileResolvedName = symbolFile.resolvedNames.get(symbol.id); + if (symbolFileResolvedName) { + if (symbolFileResolvedName !== fileResolvedName) { + name = symbolFileResolvedName; + binding.aliases[name] = fileResolvedName; + } + } else if (symbol.name && fileResolvedName !== symbol.name) { + name = symbol.name; + binding.aliases[name] = symbol.placeholder; + } + } + names.push(name); + if (symbol.meta?.kind === 'type') { + typeNames.push(name); + } + } + // cast type names to names to allow for cleaner API, + // otherwise users would have to define the same values twice + for (const typeName of typeNames) { + if (!names.includes(typeName)) { + names.push(typeName); + } + } + binding.names = names; + binding.typeNames = typeNames; + return binding; +}; + +export const mergeBindings = (target: IBinding, source: IBinding): void => { + target.aliases = { ...target.aliases, ...source.aliases }; + if (source.defaultBinding !== undefined) { + target.defaultBinding = source.defaultBinding; + } + target.names = [ + ...new Set([...(target.names ?? []), ...(source.names ?? [])]), + ]; + if (source.namespaceBinding !== undefined) { + target.namespaceBinding = source.namespaceBinding; + } + if (source.typeDefaultBinding !== undefined) { + target.typeDefaultBinding = source.typeDefaultBinding; + } + target.typeNames = [ + ...new Set([...(target.typeNames ?? []), ...(source.typeNames ?? [])]), + ]; + if (source.typeNamespaceBinding !== undefined) { + target.typeNamespaceBinding = source.typeNamespaceBinding; + } +}; diff --git a/packages/codegen-core/src/extensions/types.d.ts b/packages/codegen-core/src/extensions/types.d.ts new file mode 100644 index 000000000..092b1220f --- /dev/null +++ b/packages/codegen-core/src/extensions/types.d.ts @@ -0,0 +1,17 @@ +/** + * Arbitrary metadata passed to the project's render function. + * + * Implementers should extend this interface for their own needs. + */ +export interface IProjectRenderMeta { + [key: string]: unknown; +} + +/** + * Additional metadata about the symbol. + * + * Implementers should extend this interface for their own needs. + */ +export interface ISymbolMeta { + [key: string]: unknown; +} diff --git a/packages/codegen-core/src/files/file.ts b/packages/codegen-core/src/files/file.ts deleted file mode 100644 index 36d05a653..000000000 --- a/packages/codegen-core/src/files/file.ts +++ /dev/null @@ -1,283 +0,0 @@ -import path from 'node:path'; - -import { BiMap } from '../bimap/bimap'; -import type { ICodegenBiMap } from '../bimap/types'; -import type { ICodegenImport } from '../imports/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; - } = {}; - - private renderSymbols: Array = []; - - private state: { - exports: Map; - imports: 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); - if (meta.path) { - if (typeof meta.path === 'function') { - filePath = meta.path(filePath); - } else { - filePath = meta.path.replace('{{path}}', filePath); - } - } - this.id = project.incrementFileId(); - this.path = filePath; - } - - addExport(exp: ICodegenImport): void { - return this.addImportExport(exp, 'exports'); - } - - addImport(imp: ICodegenImport): void { - return this.addImportExport(imp, 'imports'); - } - - private addImportExport( - value: ICodegenImport, - field: 'exports' | 'imports', - ): void { - 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; // invalidate cache - } - - 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.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 { - if (!this.cache.exports) { - this.cache.exports = Array.from(this.state.exports.values()); - } - return this.cache.exports; - } - - getAllSymbols(): ReadonlyArray> { - return [ - ...this.symbols, - ...this.imports.flatMap((imp) => - (imp.names ?? []).map((name) => ({ - name: imp.aliases?.[name] ?? name, - })), - ), - ...this.exports.flatMap((imp) => - (imp.names ?? []).map((name) => ({ - name: imp.aliases?.[name] ?? name, - })), - ), - ]; - } - - 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.exports.size > 0 || this.symbols.length > 0; - } - - hasSymbol(id: number): boolean { - return this.state.symbols.has(id); - } - - get imports(): ReadonlyArray { - if (!this.cache.imports) { - this.cache.imports = Array.from(this.state.imports.values()); - } - return this.cache.imports; - } - - private mergeImportExportValues( - target: ICodegenImport, - source: ICodegenImport, - ): void { - target.aliases = { ...target.aliases, ...source.aliases }; - if (source.defaultImport !== undefined) { - target.defaultImport = source.defaultImport; - } - target.names = [ - ...new Set([...(target.names ?? []), ...(source.names ?? [])]), - ]; - if (source.namespaceImport !== undefined) { - target.namespaceImport = source.namespaceImport; - } - if (source.typeDefaultImport !== undefined) { - target.typeDefaultImport = source.typeDefaultImport; - } - target.typeNames = [ - ...new Set([...(target.typeNames ?? []), ...(source.typeNames ?? [])]), - ]; - if (source.typeNamespaceImport !== undefined) { - target.typeNamespaceImport = source.typeNamespaceImport; - } - } - - static pathToFilePath(source: string): string { - if (source.includes('/')) { - return source.split('/').filter(Boolean).join(path.sep); - } - if (source.includes('\\')) { - return source.split('\\').filter(Boolean).join(path.sep); - } - return source.split(path.sep).filter(Boolean).join(path.sep); - } - - relativePathFromFile(file: Pick): string { - let relativePath = path.posix.relative( - path.posix.dirname(file.path), - this.path, - ); - if (!relativePath.startsWith('.')) { - relativePath = `./${relativePath}`; - } - return relativePath; - } - - relativePathToFile(file: Pick): string { - let relativePath = path.posix.relative( - path.posix.dirname( - this.path.split(path.sep).join('/'), // normalize to posix - ), - file.path.split(path.sep).join('/'), // normalize to posix - ); - if (!relativePath.startsWith('.') && relativePath !== '') { - relativePath = `./${relativePath}`; - } - return relativePath; - } - - 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 = 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/registry.ts b/packages/codegen-core/src/files/registry.ts new file mode 100644 index 000000000..f0aca2521 --- /dev/null +++ b/packages/codegen-core/src/files/registry.ts @@ -0,0 +1,123 @@ +import { BiMap } from '../bimap/bimap'; +import type { ISelector } from '../selectors/types'; +import type { IFileIn, IFileOut, IFileRegistry } from './types'; + +export class FileRegistry implements IFileRegistry { + private _id: number = 0; + private referenceOrder: Set = new Set(); + private registerOrder: Set = new Set(); + private selectorToId: Map = new Map(); + private values: Map = new Map(); + + get(fileIdOrSelector: number | ISelector): IFileOut | undefined { + const symbol = this.idOrSelector(fileIdOrSelector); + + if (symbol.id !== undefined) { + return this.values.get(symbol.id); + } + + const selector = + symbol.selector !== undefined + ? JSON.stringify(symbol.selector) + : undefined; + + if (selector) { + const id = this.selectorToId.get(selector); + if (id !== undefined) { + return this.values.get(id); + } + } + + return; + } + + get id(): number { + return this._id++; + } + + private idOrSelector( + symbolIdOrSelector: number | ISelector, + ): Pick { + return typeof symbolIdOrSelector === 'number' + ? { id: symbolIdOrSelector } + : { selector: symbolIdOrSelector }; + } + + reference(fileIdOrSelector: number | ISelector): IFileOut { + const file = this.idOrSelector(fileIdOrSelector); + return this.register(file); + } + + *referenced(): IterableIterator { + for (const id of this.referenceOrder.values()) { + yield this.values.get(id)!; + } + } + + register(file: IFileIn): IFileOut { + if (file.id !== undefined) { + const result = this.values.get(file.id); + if (!result) { + throw new Error( + `File with ID ${file.id} not found. To register a new file, leave the ID undefined.`, + ); + } + return result; + } + + const hasOtherKeys = Object.keys(file).some( + (key) => !['id', 'selector'].includes(key), + ); + + let result: IFileOut | undefined; + + const selector = + file.selector !== undefined ? JSON.stringify(file.selector) : undefined; + if (selector) { + const id = this.selectorToId.get(selector); + if (id !== undefined) { + result = this.values.get(id); + if (!result) { + throw new Error( + `File with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`, + ); + } + if (!hasOtherKeys) { + return result; + } + } + } + + const id = result?.id !== undefined ? result.id : this.id; + result = { + ...result, + ...file, // clone to avoid mutation + id, + resolvedNames: result?.resolvedNames ?? new BiMap(), + symbols: result?.symbols ?? { + body: [], + exports: [], + imports: [], + }, + }; + this.values.set(id, result); + + if (hasOtherKeys) { + this.registerOrder.add(id); + } else { + this.referenceOrder.add(id); + } + + if (selector) { + this.selectorToId.set(selector, id); + } + + return result; + } + + *registered(): IterableIterator { + for (const id of this.registerOrder.values()) { + yield this.values.get(id)!; + } + } +} diff --git a/packages/codegen-core/src/files/types.d.ts b/packages/codegen-core/src/files/types.d.ts index b4740b0d6..6ba2f7b80 100644 --- a/packages/codegen-core/src/files/types.d.ts +++ b/packages/codegen-core/src/files/types.d.ts @@ -1,158 +1,113 @@ -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 { - ICodegenSymbolIn, - ICodegenSymbolOut, - SelectorMethods, -} from '../symbols/types'; +import type { IBiMap } from '../bimap/types'; +import type { ISelector } from '../selectors/types'; -export interface ICodegenFile extends SelectorMethods { +export interface IFileIn { /** - * Adds an export to this file. - * - * This is also known as a re-export. - * - * @param exp The export to add + * File extension, if any. */ - addExport(exp: ICodegenImport): void; + readonly extension?: string; /** - * Adds an import to this file. + * Indicates whether the file is external, meaning it is not generated + * as part of the project but is referenced (e.g., a module from + * node_modules). * - * @param imp The import to add + * @example true */ - addImport(imp: ICodegenImport): void; + readonly external?: boolean; /** - * Adds a symbol defined by this file. - * - * @param symbol The symbol to add + * Unique file ID. If one is not provided, it will be auto-generated. */ - addSymbol(symbol: ICodegenSymbolIn): ICodegenSymbolOut; + readonly id?: number; /** - * Ensures a symbol for the given selector exists, so it can be - * safely used. + * The desired name for the file within the project. If there are multiple files + * with the same desired name, this might not end up being the actual name. * - * @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. + * @example "UserModel" */ - ensureSymbol( - symbol: Partial & - Pick, 'selector'>, - ): ICodegenSymbolOut; + readonly name?: string; /** - * Symbols exported from other files. - **/ - exports: ReadonlyArray; - /** - * Returns all symbols used in this file (declared + imported). + * Absolute logical output path for the file. * - * @returns List of all symbols used in this file + * @example "/src/models/user.ts" */ - getAllSymbols(): ReadonlyArray>; + readonly path?: string; /** - * Finds a symbol by symbol ID. + * Selector array used to select this file. It doesn't have to be + * unique, but in practice it might be desirable. * - * @param id Symbol ID - * @returns The symbol if it exists, undefined otherwise. + * @example ["zod", "#/components/schemas/Foo"] */ - getSymbolById(id: number): ICodegenSymbolOut | undefined; + readonly selector?: ISelector; +} + +export interface IFileOut extends IFileIn { /** - * Checks if this file contains any content. - * - * This is used to determine whether we want to process the file further. - * By default, we consider only symbols and exports as content. - * - * @returns True if the file contains content + * Unique file ID. */ - hasContent(): boolean; + readonly id: number; /** - * Checks if this file defines a symbol with the given name. - * - * @param id Symbol ID to check - * @returns True if the symbol is defined by this file + * Map holding resolved names for symbols in this file. */ - hasSymbol(id: number): boolean; + readonly resolvedNames: IBiMap; /** - * File ID within the project. + * Symbols in this file, categorized by their role. */ - id: number; - /** - * Symbols imported from other files. - **/ - imports: ReadonlyArray; - /** - * Optional metadata about the file. - **/ - meta: { - /** - * Optional file extension. - * - * @example ".ts" - */ - extension?: '.ts' | (string & {}); + readonly symbols: { /** - * Optional logical module or package name. - * - * @example "models.user" + * Symbols declared in the body of this file. */ - moduleName?: string; + body: Array; /** - * Optional path transformer. - * - * @param path Original file path passed to the constructor. + * Symbols re-exported from other files. */ - path?: ((path: string) => string) | string; + exports: Array; /** - * Renderer ID. - * - * @example "typescript" + * Symbols imported from other files. */ - renderer?: ICodegenRenderer['id']; + imports: Array; }; +} + +export interface IFileRegistry { /** - * Logical output path (used for writing the file). + * Get a file by its ID. * - * @example "models/user.ts" + * @param fileIdOrSelector File ID or selector to reference. + * @returns The file, or undefined if not found. */ - path: string; + get(fileIdOrSelector: number | ISelector): IFileOut | undefined; /** - * Parent project this file belongs to. + * Returns the current file ID and increments it. + * + * @returns File ID before being incremented */ - project: ICodegenProject; + readonly id: number; /** - * Returns a relative path to this file from another file. + * Returns a file by ID or selector, registering it if it doesn't exist. * - * @param file The file from which we want the relative path to this file. - * @example "./this-file.ts" + * @param fileIdOrSelector File ID or selector to reference. + * @returns The referenced or newly registered file. */ - relativePathFromFile(file: Pick): string; + reference(fileIdOrSelector: number | ISelector): IFileOut; /** - * Returns a relative path to file from this file. + * Get all unregistered files in the order they were referenced. * - * @param file The file to which we want the relative path. - * @example "./another-file.ts" + * @returns Array of all unregistered files, in reference order. */ - relativePathToFile(file: Pick): string; + referenced(): IterableIterator; /** - * Map holding resolved names for symbols in this file. + * Register a file globally. + * + * Deduplicates identical files by ID. + * + * @param file File to register. + * @returns true if added, false if duplicate. */ - resolvedNames: ICodegenBiMap; - /** - * Top-level symbols declared in this file. - **/ - symbols: ReadonlyArray; + register(file: IFileIn): IFileOut; /** - * Updates a symbol defined by this file. + * Get all files in the order they were registered. * - * @param id ID of symbol to update. - * @param symbol The values to update. - * @returns The updated symbol. + * @returns Array of all registered files, in insert order. */ - updateSymbol( - id: number, - symbol: Partial, - ): ICodegenSymbolOut; + registered(): IterableIterator; } diff --git a/packages/codegen-core/src/index.ts b/packages/codegen-core/src/index.ts index be3437749..345a3daff 100644 --- a/packages/codegen-core/src/index.ts +++ b/packages/codegen-core/src/index.ts @@ -1,16 +1,18 @@ -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'; -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 { IBiMap as BiMap } from './bimap/types'; +export type { IBinding as Binding } from './bindings/types'; +export { createBinding, mergeBindings } from './bindings/utils'; export type { - ICodegenSymbolIn, - ICodegenSymbolOut, - ICodegenSymbolSelector, + IProjectRenderMeta as ProjectRenderMeta, + ISymbolMeta as SymbolMeta, +} from './extensions/types'; +export type { IFileOut as File, IFileIn as FileIn } from './files/types'; +export type { IOutput as Output } from './output/types'; +export { Project } from './project/project'; +export type { IProject } from './project/types'; +export type { IRenderer as Renderer } from './renderer/types'; +export { renderIds } from './renderer/utils'; +export type { ISelector as Selector } from './selectors/types'; +export type { + ISymbolOut as Symbol, + ISymbolIn as SymbolIn, } from './symbols/types'; diff --git a/packages/codegen-core/src/meta/types.d.ts b/packages/codegen-core/src/meta/types.d.ts deleted file mode 100644 index e1486202b..000000000 --- a/packages/codegen-core/src/meta/types.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Arbitrary metadata passed to render functions. - * - * Implementors should extend this interface for their own needs. - */ -export interface ICodegenMeta { - [key: string]: unknown; -} diff --git a/packages/codegen-core/src/output/types.d.ts b/packages/codegen-core/src/output/types.d.ts index c8c6b869e..7fa4a00d7 100644 --- a/packages/codegen-core/src/output/types.d.ts +++ b/packages/codegen-core/src/output/types.d.ts @@ -1,4 +1,4 @@ -export interface ICodegenOutput { +export interface IOutput { /** * The main content of the file to output. * @@ -7,13 +7,6 @@ export interface ICodegenOutput { * @example "function foo(): void {\n // implementation\n}\n" */ content: string; - /** - * Optional metadata or hints for the emitter, such as formatting options, - * source maps, or language-specific flags. - * - * @example { format: "prettier", sourceMap: true } - */ - meta: Record; /** * Logical output path (used for writing the file). * diff --git a/packages/codegen-core/src/project/project.ts b/packages/codegen-core/src/project/project.ts index b966601d2..cbdc58421 100644 --- a/packages/codegen-core/src/project/project.ts +++ b/packages/codegen-core/src/project/project.ts @@ -1,207 +1,145 @@ -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 { - ICodegenSymbolIn, - ICodegenSymbolOut, - ICodegenSymbolSelector, -} from '../symbols/types'; -import type { ICodegenProject } from './types'; - -export class CodegenProject implements ICodegenProject { - 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(); - - addExport(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void { - const file = this.ensureFile(fileOrPath); - file.addExport(imp); - } - - addImport(fileOrPath: ICodegenFile | string, imp: ICodegenImport): void { - const file = this.ensureFile(fileOrPath); - file.addImport(imp); - } - - addSymbol( - fileOrPath: ICodegenFile | string, - symbol: ICodegenSymbolIn, - ): ICodegenSymbolOut { - const file = this.ensureFile(fileOrPath); - return file.addSymbol(symbol); - } - - createFile( - path: string, - meta: Omit & { - /** - * Renderer to use to render this file. - */ - renderer?: ICodegenRenderer; - } = {}, - ): ICodegenFile { - const { renderer, ..._meta } = meta; - if (renderer) { - this.ensureRenderer(renderer); +import path from 'node:path'; + +import type { IProjectRenderMeta } from '../extensions/types'; +import { FileRegistry } from '../files/registry'; +import type { IFileOut } from '../files/types'; +import type { IOutput } from '../output/types'; +import type { IRenderer } from '../renderer/types'; +import type { ISelector } from '../selectors/types'; +import { SymbolRegistry } from '../symbols/registry'; +import type { ISymbolOut } from '../symbols/types'; +import type { IProject } from './types'; + +const externalSourceSymbol = '@'; + +export class Project implements IProject { + private symbolIdToFileIds: Map> = new Map(); + + readonly defaultFileName: string; + readonly files = new FileRegistry(); + readonly fileName?: (name: string) => string; + readonly renderers: Record = {}; + readonly root: string; + readonly symbols = new SymbolRegistry(); + + constructor({ + defaultFileName, + fileName, + renderers, + root, + }: Pick) { + this.defaultFileName = defaultFileName ?? 'main'; + this.fileName = typeof fileName === 'string' ? () => fileName : fileName; + this.renderers = renderers; + this.root = root; + } + + private getRenderer(file: IFileOut): IRenderer | undefined { + return file.extension ? this.renderers[file.extension] : undefined; + } + + private prepareFiles(): void { + // TODO: infer extension from symbols + const extension = '.ts'; + for (const symbol of this.symbols.registered()) { + const selector = this.symbolToFileSelector(symbol); + const file = this.files.reference(selector); + file.symbols.body.push(symbol.id); + // update symbol->files map + const symbolIdToFileIds = + this.symbolIdToFileIds.get(symbol.id) ?? new Set(); + symbolIdToFileIds.add(file.id); + this.symbolIdToFileIds.set(symbol.id, symbolIdToFileIds); + // update re-exports + for (const exportFrom of symbol.exportFrom) { + const exportSelector = [exportFrom]; + const exportFile = this.files.reference(exportSelector); + if (exportFile.id !== file.id) { + exportFile.symbols.exports.push(symbol.id); + } + } } - - const existing = this.getFileByPath(path); - if (existing) { - // Whoever is creating the file will override the renderer - if (renderer?.id && renderer.id !== existing.meta.renderer) { - existing.meta.renderer = renderer.id; + for (const file of this.files.referenced()) { + if (!file.selector) continue; + if (file.selector[0] === externalSourceSymbol) { + const filePath = file.selector[1]; + if (!filePath) { + this.files.register({ + external: true, + selector: file.selector, + }); + continue; + } + const extension = path.extname(filePath); + if (!extension) { + this.files.register({ + external: true, + path: filePath, + selector: file.selector, + }); + continue; + } + this.files.register({ + extension, + external: true, + path: filePath, + selector: file.selector, + }); + continue; } - return existing; + const dirs = file.selector.slice(0, -1); + let name = file.selector[file.selector.length - 1]!; + name = this.fileName?.(name) || name; + this.files.register({ + extension, + name, + path: path.resolve(this.root, ...dirs, `${name}${extension}`), + selector: file.selector, + }); } - const file = new CodegenFile(path, this, { - ..._meta, - renderer: renderer?.id, - }); - this.fileOrder.push(file); - this.filePathToFileId.set(path, file.id); - this.fileIdToFile.set(file.id, file); - return file; - } - - ensureFile(fileOrPath: ICodegenFile | string): ICodegenFile { - if (typeof fileOrPath !== 'string') { - return fileOrPath; - } - const existingFile = this.getFileByPath(fileOrPath); - if (existingFile) { - return existingFile; + // TODO: track symbol dependencies and inject imports into files + // based on symbol references so the render step can just render + } + + render(meta?: IProjectRenderMeta): ReadonlyArray { + this.prepareFiles(); + const files: Map = new Map(); + for (const file of this.files.registered()) { + if (file.external || !file.path) continue; + const renderer = this.getRenderer(file); + if (!renderer) continue; + files.set(file.id, { + content: renderer.renderSymbols(file, this, meta), + path: file.path, + }); } - return this.createFile(fileOrPath); - } - - private ensureRenderer(renderer: ICodegenRenderer): ICodegenRenderer { - if (!this.renderers.has(renderer.id)) { - this.renderers.set(renderer.id, renderer); + for (const [fileId, value] of files.entries()) { + const file = this.files.get(fileId)!; + const renderer = this.getRenderer(file)!; + const content = renderer.renderFile(value.content, file, this, meta); + if (content) { + files.set(file.id, { ...value, content }); + } else { + files.delete(file.id); + } } - return this.renderers.get(renderer.id)!; - } - - get files(): ReadonlyArray { - return [...this.fileOrder]; - } - - getAllSymbols(): ReadonlyArray> { - return this.fileOrder.flatMap((file) => file.getAllSymbols()); + return Array.from(files.values()); } - getFileByPath(path: string): ICodegenFile | undefined { - const fileId = this.filePathToFileId.get(path); - return fileId !== undefined ? this.fileIdToFile.get(fileId) : undefined; + symbolIdToFiles(symbolId: number): ReadonlyArray { + const fileIds = this.symbolIdToFileIds.get(symbolId); + return Array.from(fileIds ?? []).map((fileId) => this.files.get(fileId)!); } - 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); + private symbolToFileSelector(symbol: ISymbolOut): ISelector { + if (symbol.external) { + return [externalSourceSymbol, symbol.external]; } - } - - render(meta?: ICodegenMeta): ReadonlyArray { - const results: Array = []; - 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); + const filePath = symbol.getFilePath?.(symbol); + if (filePath) { + return filePath.split('/'); } - 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]; + return [this.defaultFileName]; } } diff --git a/packages/codegen-core/src/project/types.d.ts b/packages/codegen-core/src/project/types.d.ts index b60f1c779..22d2c6ba7 100644 --- a/packages/codegen-core/src/project/types.d.ts +++ b/packages/codegen-core/src/project/types.d.ts @@ -1,146 +1,69 @@ -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 type { ICodegenRenderer } from '../renderers/types'; -import type { - ICodegenSymbolIn, - ICodegenSymbolOut, - SelectorMethods, -} from '../symbols/types'; +import type { IProjectRenderMeta } from '../extensions/types'; +import type { IFileOut, IFileRegistry } from '../files/types'; +import type { IOutput } from '../output/types'; +import type { IRenderer } from '../renderer/types'; +import type { ISymbolRegistry } 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 extends SelectorMethods { +export interface IProject { /** - * Adds an export declaration to a specific file, creating the file if it doesn't exist. + * The default file to assign symbols without a specific file selector. * - * @param fileOrPath - File instance or file path where to add the export. - * @param imp - The export declaration to add. - * @example - * project.addExport("models/user.ts", { from: "lib", names: ["User"] }); - */ - 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.addImport("models/user.ts", { from: "lib", names: ["User"] }); - */ - 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.addSymbol("models/user.ts", { name: "User", value: tsNode }); - */ - addSymbol( - fileOrPath: ICodegenFile | string, - symbol: ICodegenSymbolIn, - ): ICodegenSymbolOut; - /** - * Creates a new codegen file with optional metadata and adds it to the project. - * - * If a file with the same path already exists, it is returned instead. - * - * @param path - The logical output path for the file (e.g. "models/user.ts"). - * @param meta - Optional renderer and metadata to attach to the file (e.g. { isInternal: true }). - * @returns The newly created file instance. - * @example - * const file = project.createFile("models/user.ts", { isInternal: true }); + * @default 'main' */ - createFile( - path: string, - meta?: ICodegenFile['meta'] & { renderer?: ICodegenRenderer }, - ): ICodegenFile; + readonly defaultFileName?: string; /** - * Ensures a codegen file exists and returns it. - * - * If a file does not exist yet, it is created with minimal information. - * Later, it is expected `createFile()` will be called which will fill in - * the missing information such as optional metadata. + * Optional function to transform file names before they are used. * - * @param fileOrPath - The logical output path for the file or the file itself. - * @returns The file instance. - * @example - * const file = project.ensureFile("models/user.ts"); + * @param name The original file name. + * @returns The transformed file name. */ - ensureFile(fileOrPath: ICodegenFile | string): ICodegenFile; + readonly fileName?: (name: string) => string; /** - * Returns all files in the project in insertion order. - * - * @example - * project.files.forEach(file => console.log(file.path)); + * Centralized file registry for the project. */ - readonly files: ReadonlyArray; + readonly files: IFileRegistry; /** - * Returns all symbols declared or imported across all files. + * Produces output representations for all files in the project. * - * @returns Flattened list of all codegen symbols. + * @param meta Arbitrary metadata. + * @returns Array of outputs ready for writing or further processing. * @example - * project.getAllSymbols().filter(s => s.name === "User"); + * project.render().forEach(output => writeFile(output)); */ - getAllSymbols(): ReadonlyArray>; + render(meta?: IProjectRenderMeta): ReadonlyArray; /** - * Retrieves a file by its logical output path. + * Map of available renderers by file extension. * - * @param path - The file path to find. - * @returns The file if found, or undefined otherwise. * @example - * const file = project.getFileByPath("models/user.ts"); + * { + * ".ts": tsRenderer, + * ".js": jsRenderer, + * } */ - getFileByPath(path: string): ICodegenFile | undefined; + readonly renderers: Record; /** - * 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); + * The absolute path to the root folder of the project. */ - getFileBySymbolId(id: number): ICodegenFile | undefined; + readonly root: string; /** - * Retrieves a symbol from ID included in the project. + * Retrieves files that include symbol ID. The first file is the one + * where the symbol is declared, the rest are files that re-export it. * - * @param id The symbol ID to find. - * @returns The symbol if found, undefined otherwise. + * @param symbolId The symbol ID to find. + * @returns An array of files containing the symbol. * @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 + * const files = project.symbolIdToFiles(31); + * for (const file of files) { + * console.log(file.path); + * } */ - incrementSymbolId(): number; + symbolIdToFiles(symbolId: number): ReadonlyArray; /** - * 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. - * - * @param meta Arbitrary metadata. - * @returns Array of outputs ready for writing or further processing. - * @example - * project.render().forEach(output => writeFile(output)); + * Centralized symbol registry for the project. */ - render(meta?: ICodegenMeta): ReadonlyArray; + readonly symbols: ISymbolRegistry; } diff --git a/packages/codegen-core/src/renderer/types.d.ts b/packages/codegen-core/src/renderer/types.d.ts new file mode 100644 index 000000000..651d28c0c --- /dev/null +++ b/packages/codegen-core/src/renderer/types.d.ts @@ -0,0 +1,33 @@ +import type { IProjectRenderMeta } from '../extensions/types'; +import type { IFileOut } from '../files/types'; +import type { IProject } from '../project/types'; + +export interface IRenderer { + /** + * Renders content with replaced symbols. + * + * @param content Content to render. + * @param file The file to render. + * @param project The parent project the file belongs to. + * @returns Rendered content. + */ + renderFile( + content: string, + file: IFile, + project: IProject, + meta?: IProjectRenderMeta, + ): string; + /** + * Returns printable data containing symbols and exports. + * + * @param file The file to render. + * @param project The parent project the file belongs to. + * @param meta Arbitrary metadata. + * @returns Printable string containing symbols and exports. + */ + renderSymbols( + file: IFileOut, + project: IProject, + meta?: IProjectRenderMeta, + ): string; +} diff --git a/packages/codegen-core/src/renderers/renderer.ts b/packages/codegen-core/src/renderer/utils.ts similarity index 96% rename from packages/codegen-core/src/renderers/renderer.ts rename to packages/codegen-core/src/renderer/utils.ts index 184c69316..608c07f9f 100644 --- a/packages/codegen-core/src/renderers/renderer.ts +++ b/packages/codegen-core/src/renderer/utils.ts @@ -28,7 +28,7 @@ const createPlaceholderRegExp = (): RegExp => new RegExp(wrapId('\\d+'), 'g'); * @param replacerFn Accepts a symbol ID, returns resolved symbol name. * @returns The replaced source string. */ -export const replaceWrappedIds = ( +export const renderIds = ( source: string, replacerFn: (symbolId: number) => string | undefined, ): string => diff --git a/packages/codegen-core/src/renderers/types.d.ts b/packages/codegen-core/src/renderers/types.d.ts deleted file mode 100644 index bcb7e0757..000000000 --- a/packages/codegen-core/src/renderers/types.d.ts +++ /dev/null @@ -1,42 +0,0 @@ -import type { ICodegenFile } from '../files/types'; -import type { ICodegenMeta } from '../meta/types'; - -export interface ICodegenRenderer { - /** - * Optional: hook for renderer-level setup logic (e.g., formatting, config) - */ - configure?(options: Record): void; - /** - * Unique identifier for this renderer. - * - * @example "typescript" - */ - id: string; - /** - * Returns printable data containing header and imports. - * - * @param file The file to render. - * @param meta Arbitrary metadata. - * @returns Printable string containing header and imports. - */ - 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/selectors/types.d.ts b/packages/codegen-core/src/selectors/types.d.ts new file mode 100644 index 000000000..ef7ecfd04 --- /dev/null +++ b/packages/codegen-core/src/selectors/types.d.ts @@ -0,0 +1,7 @@ +/** + * Selector array used to reference resources. We don't enforce + * uniqueness, but in practice it's desirable. + * + * @example ["zod", "#/components/schemas/Foo"] + */ +export type ISelector = ReadonlyArray; diff --git a/packages/codegen-core/src/symbols/registry.ts b/packages/codegen-core/src/symbols/registry.ts new file mode 100644 index 000000000..a98987642 --- /dev/null +++ b/packages/codegen-core/src/symbols/registry.ts @@ -0,0 +1,132 @@ +import { wrapId } from '../renderer/utils'; +import type { ISelector } from '../selectors/types'; +import type { ISymbolIn, ISymbolOut, ISymbolRegistry } from './types'; + +export class SymbolRegistry implements ISymbolRegistry { + private _id: number = 0; + private nodes: Map = new Map(); + private registerOrder: Set = new Set(); + private selectorToId: Map = new Map(); + private values: Map = new Map(); + + get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined { + const symbol = this.idOrSelector(symbolIdOrSelector); + + if (symbol.id !== undefined) { + return this.values.get(symbol.id); + } + + const selector = + symbol.selector !== undefined + ? JSON.stringify(symbol.selector) + : undefined; + + if (selector) { + const id = this.selectorToId.get(selector); + if (id !== undefined) { + return this.values.get(id); + } + } + + return; + } + + getValue(symbolId: number): unknown { + return this.nodes.get(symbolId); + } + + hasValue(symbolId: number): boolean { + return this.nodes.has(symbolId); + } + + get id(): number { + return this._id++; + } + + private idOrSelector( + symbolIdOrSelector: number | ISelector, + ): Pick { + return typeof symbolIdOrSelector === 'number' + ? { id: symbolIdOrSelector } + : { selector: symbolIdOrSelector }; + } + + reference(symbolIdOrSelector: number | ISelector): ISymbolOut { + const symbol = this.idOrSelector(symbolIdOrSelector); + return this.register(symbol); + } + + register(symbol: ISymbolIn): ISymbolOut { + if (symbol.id !== undefined) { + const result = this.values.get(symbol.id); + if (!result) { + throw new Error( + `Symbol with ID ${symbol.id} not found. To register a new symbol, leave the ID undefined.`, + ); + } + return result; + } + + const hasOtherKeys = Object.keys(symbol).some( + (key) => !['id', 'selector'].includes(key), + ); + + let result: ISymbolOut | undefined; + + const selector = + symbol.selector !== undefined + ? JSON.stringify(symbol.selector) + : undefined; + if (selector) { + const id = this.selectorToId.get(selector); + if (id !== undefined) { + result = this.values.get(id); + if (!result) { + throw new Error( + `Symbol with ID ${id} not found. The selector ${selector} matched an ID, but there was no result. This is likely an issue with the application logic.`, + ); + } + if (!hasOtherKeys) { + return result; + } + } + } + + const id = result?.id !== undefined ? result.id : this.id; + const exportFrom: Array = result?.exportFrom + ? [...result.exportFrom] + : []; + if (symbol.exportFrom) { + exportFrom.push(...symbol.exportFrom); + } + result = { + ...result, + ...symbol, // clone to avoid mutation + exportFrom, + id, + placeholder: + result?.placeholder ?? symbol.placeholder ?? wrapId(String(id)), + }; + this.values.set(id, result); + + if (hasOtherKeys) { + this.registerOrder.add(id); + } + + if (selector) { + this.selectorToId.set(selector, id); + } + + return result; + } + + *registered(): IterableIterator { + for (const id of this.registerOrder.values()) { + yield this.values.get(id)!; + } + } + + setValue(symbolId: number, value: unknown): Map { + return this.nodes.set(symbolId, value); + } +} diff --git a/packages/codegen-core/src/symbols/types.d.ts b/packages/codegen-core/src/symbols/types.d.ts index e9029605a..cd8f68111 100644 --- a/packages/codegen-core/src/symbols/types.d.ts +++ b/packages/codegen-core/src/symbols/types.d.ts @@ -1,60 +1,78 @@ -import type { ICodegenFile } from '../files/types'; +import type { ISymbolMeta } from '../extensions/types'; +import type { ISelector } from '../selectors/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 { +export interface ISymbolIn { /** - * Symbols can be **headed** or **headless**. - * - * Headless symbols never render their `value`. Headed symbols render their - * `value` if defined. + * Array of file names (without extensions) from which this symbol is re-exported. * - * Symbols are rendered in the order they were registered as headed. + * @default undefined + */ + readonly exportFrom?: ReadonlyArray; + /** + * Whether this symbol is exported from its own file. * - * Example 1: We register headless symbol `foo`, headed `bar`, and headed - * `foo`. The render order is [`bar`, `foo`]. + * @default false + */ + readonly exported?: boolean; + /** + * External module name if this symbol is imported from a module not managed + * by the project (e.g. "zod", "lodash"). * - * Example 2: We register headed symbol `foo` and headed `bar`. The render - * order is [`foo`, `bar`]. + * @default undefined + */ + readonly external?: string; + /** + * Optional output strategy to override default behavior. * - * Headless symbols can be used to claim a symbol or to represent imports - * or exports. + * @returns The file path to output the symbol to, or undefined to fallback to default behavior. + */ + readonly getFilePath?: (symbol: ISymbolOut) => string | undefined; + /** + * Unique symbol ID. If one is not provided, it will be auto-generated. + */ + readonly id?: number; + /** + * Arbitrary metadata about the symbol. * - * @default false + * @default undefined */ - headless?: boolean; + readonly meta?: ISymbolMeta & { + /** + * Kind of import if this symbol represents an import. + */ + importKind?: 'namespace' | 'default' | 'named'; + /** + * Kind of symbol. + */ + kind?: 'type'; + }; /** * 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 "UserModel" */ - readonly name: string; + readonly name?: string; + /** + * Placeholder name for the symbol to be replaced later with the final value. + * + * @example "_heyapi_31_" + */ + readonly placeholder?: string; /** * Selector array used to select this symbol. It doesn't have to be * unique, but in practice it might be desirable. * * @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; + readonly selector?: ISelector; } -export interface ICodegenSymbolOut extends ICodegenSymbolIn { +export interface ISymbolOut extends ISymbolIn { /** - * The file this symbol is located in. + * Array of file names (without extensions) from which this symbol is re-exported. */ - readonly file: ICodegenFile; + readonly exportFrom: ReadonlyArray; /** * Unique symbol ID. */ @@ -65,66 +83,64 @@ export interface ICodegenSymbolOut extends ICodegenSymbolIn { * @example "_heyapi_31_" */ readonly placeholder: string; +} + +export interface ISymbolRegistry { /** - * Updates this symbol. + * Get a symbol by its ID. * - * @param symbol The values to update. - * @returns The updated symbol. + * @param symbolIdOrSelector Symbol ID or selector to reference. + * @returns The symbol, or undefined if not found. */ - 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"]); - */ - selectSymbolLast( - selector: ICodegenSymbolSelector, - file?: ICodegenFile, - ): ICodegenSymbolOut | undefined; + get(symbolIdOrSelector: number | ISelector): ISymbolOut | undefined; + /** + * Returns the value associated with a symbol ID. + * + * @param symbolId Symbol ID. + * @return The value associated with the symbol ID, or undefined if not found. + */ + getValue(symbolId: number): unknown; + /** + * Checks if the registry has a value associated with a symbol ID. + * + * @param symbolId Symbol ID. + * @returns True if the registry has a value for symbol ID, false otherwise. + */ + hasValue(symbolId: number): boolean; + /** + * Returns the current symbol ID and increments it. + * + * @returns Symbol ID before being incremented. + */ + readonly id: number; + /** + * Returns a symbol by ID or selector, registering it if it doesn't exist. + * + * @param symbolIdOrSelector Symbol ID or selector to reference. + * @returns The referenced or newly registered symbol. + */ + reference(symbolIdOrSelector: number | ISelector): ISymbolOut; + /** + * Register a symbol globally. + * + * Deduplicates identical symbols by ID. + * + * @param symbol Symbol to register. + * @returns The registered symbol. + */ + register(symbol: ISymbolIn): ISymbolOut; + /** + * Get all symbols in the order they were registered. + * + * @returns Array of all registered symbols, in insert order. + */ + registered(): IterableIterator; + /** + * Sets a value for a symbol by its ID. + * + * @param symbolId Symbol ID. + * @param value The value to set. + * @returns void + */ + setValue(symbolId: number, value: unknown): Map; } diff --git a/packages/custom-client/src/plugin.ts b/packages/custom-client/src/plugin.ts index fc868ad33..7d4ddc8d7 100644 --- a/packages/custom-client/src/plugin.ts +++ b/packages/custom-client/src/plugin.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 62bdb7f98..00338555a 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type Foo = { foo: string; }; @@ -9,7 +13,3 @@ export type Bar = Foo & {}; export type Baz = Foo & { bar: string; }; - -export type ClientOptions = { - baseUrl: string; -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 067709e9c..4585c357e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type Foo = { foo: string; [key: string]: unknown | string; @@ -17,7 +21,3 @@ export type Baz = Foo & { export type Qux = { [key: string]: unknown; }; - -export type ClientOptions = { - baseUrl: string; -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 d0712e097..0c52381d2 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/types.gen.ts index dc6943369..01dd71cbd 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type PostFooData = { body: string; path?: never; @@ -15,7 +19,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/types.gen.ts index 752a77a58..22744bba6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-PascalCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export const _110 = { 110: '1-10', 1120: '11-20' @@ -49,7 +53,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts index fb55304b4..4d23f2917 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-SCREAMING_SNAKE_CASE/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export const _110 = { '1_10': '1-10', '11_20': '11-20' @@ -49,7 +53,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/types.gen.ts index 8dcf013dd..0ca18993d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-camelCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export const _110 = { 110: '1-10', 1120: '11-20' @@ -49,7 +53,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/types.gen.ts index df988a03d..3efeb697a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-preserve/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export const _110 = { '1-10': '1-10', '11-20': '11-20' @@ -49,7 +53,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/types.gen.ts index a0cf12a01..5c735bac3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-javascript-snake_case/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export const _110 = { '1_10': '1-10', '11_20': '11-20' @@ -49,7 +53,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/types.gen.ts index 7352108dc..c4db83602 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-PascalCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export enum _110 { _110 = '1-10', _1120 = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts index cde22290f..d29c33f61 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-SCREAMING_SNAKE_CASE/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export enum _110 { '1_10' = '1-10', '11_20' = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/types.gen.ts index 16ea57219..be7cbd0e5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-camelCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export enum _110 { _110 = '1-10', _1120 = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/types.gen.ts index 658609c2a..bbcdebda6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-const/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export const enum _110 { _110 = '1-10', _1120 = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/types.gen.ts index e8450c407..57e45fac7 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-preserve/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export enum _110 { '1-10' = '1-10', '11-20' = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/types.gen.ts index 538bc4b3c..3d87fcc64 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values-typescript-snake_case/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export enum _110 { '1_10' = '1-10', '11_20' = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/types.gen.ts index 9452f2b9e..6ec248809 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/enum-names-values/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type _110 = '1-10' | '11-20'; export type MyFoo = 'myFoo' | 'myBar'; @@ -17,7 +21,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/types.gen.ts index 2f6988dd6..ff23db4fc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/exclude-deprecated/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type Foo = string; export type PostFooData = { @@ -15,7 +19,3 @@ export type PostFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 3d1e1fbe6..3302d8733 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type ExternalSchemaA = ExternalSharedExternalSharedModel; export type ExternalSchemaB = ExternalSharedExternalSharedModel; @@ -388,7 +392,3 @@ export type GetExternalPropertiesByIdResponses = { }; export type GetExternalPropertiesByIdResponse = GetExternalPropertiesByIdResponses[keyof GetExternalPropertiesByIdResponses]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 99b508c95..253cdc0ff 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options as ClientOptions, type Client, type TDataShape, formDataBodySerializer } from './client'; -import type { PostV1FooData, PostV1FooResponses } from './types.gen'; +import { type TDataShape, type Options as Options2, type Client, formDataBodySerializer } from './client'; import { client } from './client.gen'; +import type { PostV1FooData, PostV1FooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 7b434343a..997ebc24b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type Foo = { status?: number; }; @@ -22,7 +26,3 @@ export type PostV1FooResponses = { }; export type PostV1FooResponse = PostV1FooResponses[keyof PostV1FooResponses]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts new file mode 100644 index 000000000..f980e3995 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts @@ -0,0 +1,794 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type HttpRequest, httpResource } from '@angular/common/http'; +import { Injectable, inject } from '@angular/core'; + +import { client } from '../client.gen'; +import type { Options } from '../sdk.gen'; +import type { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, PostApiVbyApiVersionBodyData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, DummyAData, DummyBData, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PostApiVbyApiVersionBodyResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, TypesResponse, ComplexTypesResponse, NonAsciiæøåÆøÅöôêÊ字符串Response } from '../types.gen'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultServiceRequests { + 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 SimpleServiceRequests { + 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 DescriptionsServiceRequests { + 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 ParametersServiceRequests { + 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 DefaultsServiceRequests { + 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 DuplicateServiceRequests { + 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 NoContentServiceRequests { + 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 ResponseServiceRequests { + 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 MultipleTags1ServiceRequests { + 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 MultipleTags2ServiceRequests { + 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 MultipleTags3ServiceRequests { + 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 CollectionFormatServiceRequests { + 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 TypesServiceRequests { + 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 ComplexServiceRequests { + 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 HeaderServiceRequests { + 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 ErrorServiceRequests { + 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ÆøåÆøÅöôêÊServiceRequests { + public nonAsciiæøåÆøÅöôêÊ字符串(options: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'POST', + url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串', + ...options + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultServiceResources { + public serviceWithEmptyTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).serviceWithEmptyTag(opts) : undefined; + }); + } + + public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + }); + } + + public fooWow(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).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(DefaultServiceRequests).postApiVbyApiVersionBody(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleServiceResources { + public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsServiceResources { + public callWithDescriptions(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersServiceResources { + public callWithParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; + }); + } + + public callWithWeirdParameterNames(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsServiceResources { + public callWithDefaultParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; + }); + } + + public callWithDefaultOptionalParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; + }); + } + + public callToTestOrderOfParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateServiceResources { + public duplicateName(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; + }); + } + + public duplicateName2(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; + }); + } + + public duplicateName3(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; + }); + } + + public duplicateName4(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentServiceResources { + public callWithNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; + }); + } + + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseServiceResources { + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } + + public callWithResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; + }); + } + + public callWithDuplicateResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; + }); + } + + public callWithResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1ServiceResources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2ServiceResources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3ServiceResources { + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatServiceResources { + public collectionFormat(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesServiceResources { + public types(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(TypesServiceRequests).types(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexServiceResources { + public complexTypes(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderServiceResources { + public callWithResultFromHeader(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorServiceResources { + public testErrorCode(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊServiceResources { + public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : 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/@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 deleted file mode 100644 index 1f9271d48..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts +++ /dev/null @@ -1,438 +0,0 @@ -// 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 DefaultServiceRequests { - 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 SimpleServiceRequests { - 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 DescriptionsServiceRequests { - 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 ParametersServiceRequests { - 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 DefaultsServiceRequests { - 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 DuplicateServiceRequests { - 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 NoContentServiceRequests { - 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 ResponseServiceRequests { - 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 MultipleTags1ServiceRequests { - 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 MultipleTags2ServiceRequests { - 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 MultipleTags3ServiceRequests { - 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 CollectionFormatServiceRequests { - 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 TypesServiceRequests { - 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 ComplexServiceRequests { - 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 HeaderServiceRequests { - 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 ErrorServiceRequests { - 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ÆøåÆøÅöôêÊServiceRequests { - 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 deleted file mode 100644 index 53da1170d..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts +++ /dev/null @@ -1,362 +0,0 @@ -// 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 { 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 DefaultServiceResources { - public serviceWithEmptyTag(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).serviceWithEmptyTag(opts) : undefined; - }); - } - - public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; - }); - } - - public fooWow(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).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(DefaultServiceRequests).postApiVbyApiVersionBody(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class SimpleServiceResources { - public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DescriptionsServiceResources { - public callWithDescriptions(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ParametersServiceResources { - public callWithParameters(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; - }); - } - - public callWithWeirdParameterNames(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DefaultsServiceResources { - public callWithDefaultParameters(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; - }); - } - - public callWithDefaultOptionalParameters(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; - }); - } - - public callToTestOrderOfParams(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DuplicateServiceResources { - public duplicateName(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; - }); - } - - public duplicateName2(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; - }); - } - - public duplicateName3(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; - }); - } - - public duplicateName4(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class NoContentServiceResources { - public callWithNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; - }); - } - - public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ResponseServiceResources { - public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; - }); - } - - public callWithResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; - }); - } - - public callWithDuplicateResponses(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; - }); - } - - public callWithResponses(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags1ServiceResources { - public dummyA(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; - }); - } - - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags2ServiceResources { - public dummyA(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; - }); - } - - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags3ServiceResources { - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class CollectionFormatServiceResources { - public collectionFormat(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class TypesServiceResources { - public types(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(TypesServiceRequests).types(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ComplexServiceResources { - public complexTypes(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class HeaderServiceResources { - public callWithResultFromHeader(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ErrorServiceResources { - public testErrorCode(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class NonAsciiÆøåÆøÅöôêÊServiceResources { - public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : 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 950198e01..6b55ac80f 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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-class/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/index.ts index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index b215924fa..d93ccb7c0 100644 --- 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 @@ -1,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 index b0edf4e79..37a560625 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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.gen.ts similarity index 51% rename from packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common.gen.ts index cdc646474..503bea246 100644 --- 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.gen.ts @@ -1,9 +1,10 @@ // 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 { type HttpRequest, httpResource } from '@angular/common/http'; + +import { client } from '../client.gen'; +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, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, TypesResponse, ComplexTypesResponse, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyResponse } from '../types.gen'; export const serviceWithEmptyTagRequest = (options?: Options): HttpRequest => { return (options?.client ?? client).requestOptions({ @@ -314,3 +315,245 @@ export const postApiVbyApiVersionBodyRequest = (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/@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 deleted file mode 100644 index df3ac474b..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts +++ /dev/null @@ -1,248 +0,0 @@ -// 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 index 950198e01..6b55ac80f 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/index.ts index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index b215924fa..d93ccb7c0 100644 --- 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 @@ -1,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 index b0edf4e79..37a560625 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/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 e28017eaf..7f92a6b23 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' })); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2d5985b31..91bd50dc5 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, BusinessGetData, BusinessGetResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, GetData, GetResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -30,7 +30,7 @@ class _HeyApiClient { } } -class Domains extends _HeyApiClient { +export class Domains extends _HeyApiClient { public get(options?: Options) { return (options?.client ?? this._client).get({ url: '/business/providers/domains', @@ -46,11 +46,11 @@ class Domains extends _HeyApiClient { } } -class Providers extends _HeyApiClient { +export class Providers extends _HeyApiClient { domains = new Domains({ client: this._client }); } -class Business extends _HeyApiClient { +export class Business extends _HeyApiClient { public get(options?: Options) { return (options?.client ?? this._client).get({ url: '/locations/businesses', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts index 3c9d90569..3f503a59d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'https://api.example.com/v1' | (string & {}); +}; + export type BusinessProvidersDomainsGetData = { body?: never; path?: never; @@ -79,7 +83,3 @@ export type GetResponses = { }; export type GetResponse = GetResponses[keyof GetResponses]; - -export type ClientOptions = { - baseUrl: 'https://api.example.com/v1' | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts index e28017eaf..7f92a6b23 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' })); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 4ff334ff7..58f593d8a 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class Domains { +export class Domains { public static get(options?: Options) { return (options?.client ?? client).get({ url: '/business/providers/domains', @@ -41,7 +41,7 @@ class Domains { } } -class Providers { +export class Providers { static domains = Domains; } 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 3c9d90569..3f503a59d 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'https://api.example.com/v1' | (string & {}); +}; + export type BusinessProvidersDomainsGetData = { body?: never; path?: never; @@ -79,7 +83,3 @@ export type GetResponses = { }; export type GetResponse = GetResponses[keyof GetResponses]; - -export type ClientOptions = { - baseUrl: 'https://api.example.com/v1' | (string & {}); -}; 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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/@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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 b215924fa..d93ccb7c0 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 4cf0ca9c4..2d511cf07 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -30,7 +30,7 @@ class _HeyApiClient { } } -class Bar extends _HeyApiClient { +export class Bar extends _HeyApiClient { public post(options?: Options) { return (options?.client ?? this._client).post({ url: '/foo/bar', @@ -46,7 +46,7 @@ class Bar extends _HeyApiClient { } } -class Foo extends _HeyApiClient { +export class Foo extends _HeyApiClient { public post(options?: Options) { return (options?.client ?? this._client).post({ url: '/foo', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/types.gen.ts index 28d798a00..9844839de 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts index 7190dd07b..778e50856 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,9 +11,9 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base', throwOnError: true })); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 4140ac376..f4f9f2b61 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 5c161731c..1f8bf6602 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,13 +1,14 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; -import { vPostFooData, vPostFooResponse } from './valibot.gen'; import * as v from 'valibot'; -import { postFooResponseTransformer } from './transformers.gen'; + +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; +import { vPostFooData, vPostFooResponse } from './valibot.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 cc9dcf841..ea991c983 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 @@ -2,12 +2,12 @@ import type { PostFooResponse } from './types.gen'; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = BigInt(data.foo.toString()); +export const postFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -export const postFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = BigInt(data.foo.toString()); return data; }; 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 2b264a4ce..b8aa017cd 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 @@ -1,5 +1,13 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + +export type TypeID = `${T}_${string}`; + +export type UserId = TypeID<'user'>; + export type Foo = { bar?: number; foo: bigint; @@ -26,11 +34,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type TypeID = `${T}_${string}`; - -export type UserId = TypeID<'user'>; - -export type ClientOptions = { - baseUrl: string; -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 9067c31ee..e6ec9cb52 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,12 +1,12 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { TDataShape, Options as Options2, Client } from './client'; +import { client } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; import type { PostFooData, PostFooResponses } from './types.gen'; import { zPostFooData, zPostFooResponse } from './zod.gen'; -import { postFooResponseTransformer } from './transformers.gen'; -import { client } from './client.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 cc9dcf841..ea991c983 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 @@ -2,12 +2,12 @@ import type { PostFooResponse } from './types.gen'; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = BigInt(data.foo.toString()); +export const postFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -export const postFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = BigInt(data.foo.toString()); return data; }; 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 2b264a4ce..b8aa017cd 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 @@ -1,5 +1,13 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + +export type TypeID = `${T}_${string}`; + +export type UserId = TypeID<'user'>; + export type Foo = { bar?: number; foo: bigint; @@ -26,11 +34,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type TypeID = `${T}_${string}`; - -export type UserId = TypeID<'user'>; - -export type ClientOptions = { - baseUrl: string; -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a7f908ad2..db3956e79 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type Baz = { baz?: string; }; @@ -55,7 +59,3 @@ export type PostFooReadResponses = { }; export type PostFooReadResponse = PostFooReadResponses[keyof PostFooReadResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 54931798c..6ab8910b7 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type FooRead = BarRead & { readonly foo?: string; }; @@ -43,7 +47,3 @@ export type PostFooReadResponses = { }; export type PostFooReadResponse = PostFooReadResponses[keyof PostFooReadResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 index e31c2880d..a19022118 100644 --- 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 @@ -1,9 +1,10 @@ // 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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, GetFooResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 index fe57f118d..cab3c7019 100644 --- 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +export const client = createClient(createConfig()); 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 index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index 353557eb6..95671b708 100644 --- 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 @@ -1,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 index 28d798a00..9844839de 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 9b66b5118..b4ca9d1c9 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, TypesResponse, ComplexTypesData, ComplexTypesResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/@pinia/colada/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 b215924fa..d93ccb7c0 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 01f8e2d24..7d91375f4 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 5edad337f..7d18a4603 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { AxiosError } from 'axios'; + import { client } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 84d57fda4..e801ca3f6 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 742676468..e06f04f51 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 8d3bdd514..f29ed5c75 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 b215924fa..d93ccb7c0 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 cc71b7997..2e9bb8e0b 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 4dfbf97a8..89d6c36e2 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 8f1ad7c35..19897d1de 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { AxiosError } from 'axios'; + import { client } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/react-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 84d57fda4..e801ca3f6 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 742676468..e06f04f51 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 244f7d8d0..7124c7bda 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/react-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 b215924fa..d93ccb7c0 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 80cf0ec00..e28573f3a 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 df3b287f4..36484b5ca 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 88d9a436a..26046c97b 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { AxiosError } from 'axios'; + import { client } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/solid-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 84d57fda4..e801ca3f6 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 742676468..e06f04f51 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 e3d114c97..0b369e639 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/solid-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 b215924fa..d93ccb7c0 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 392d84621..6bc30992c 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 c8e3b0f3f..2e10ae9ef 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 927760423..84195d1eb 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { AxiosError } from 'axios'; + import { client } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/svelte-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 84d57fda4..e801ca3f6 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 742676468..e06f04f51 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 70f5b99be..381286d22 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/svelte-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 b215924fa..d93ccb7c0 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 98f162beb..664941756 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 cbbcb26a7..8e51a85ec 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 bf63c8f5b..352f9bd8b 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { AxiosError } from 'axios'; + import { client } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/vue-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 84d57fda4..e801ca3f6 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 742676468..e06f04f51 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 0eef4016f..c775bdfe2 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +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 { ServiceWithEmptyTagData, PatchApiVbyApiVersionNoTagData, FooWowData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, DummyAData, DummyBData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, ComplexTypesData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyResponse, PostApiVbyApiVersionBodyError } from '../types.gen'; export type QueryKey = [ Pick & { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/vue-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 b215924fa..d93ccb7c0 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/@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 463216f2d..bb9cf3b21 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 28d798a00..9844839de 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 b131cb6ce..845122076 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 @@ -1,8 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseResponses, DummyAResponses, DummyBResponses, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyErrors, PostApiVbyApiVersionBodyResponses } from './types.gen'; import type { RouteHandler } from 'fastify'; +import type { CallWithDescriptionsData, CallWithParametersData, CallWithWeirdParameterNamesData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, CallWithNoContentResponseResponses, CallWithResponseAndNoContentResponseResponses, DummyAResponses, DummyBResponses, CallWithDuplicateResponsesErrors, CallWithDuplicateResponsesResponses, CallWithResponsesErrors, CallWithResponsesResponses, CollectionFormatData, TypesData, TypesResponses, ComplexTypesData, ComplexTypesErrors, ComplexTypesResponses, CallWithResultFromHeaderErrors, CallWithResultFromHeaderResponses, TestErrorCodeData, TestErrorCodeErrors, TestErrorCodeResponses, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Responses, PostApiVbyApiVersionBodyData, PostApiVbyApiVersionBodyErrors, PostApiVbyApiVersionBodyResponses } from './types.gen'; + export type RouteHandlers = { callWithDescriptions: RouteHandler<{ Querystring?: CallWithDescriptionsData['query']; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 b0edf4e79..37a560625 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + export type ExternalRefA = ExternalSharedExternalSharedModel; export type ExternalRefB = ExternalSharedExternalSharedModel; @@ -1172,7 +1176,3 @@ export type PostApiVbyApiVersionBodyResponses = { }; 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/schema-unknown/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client.gen.ts index fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 e5bff5c84..a2ec6738e 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { SendEmailData, SendEmailResponses, SendEmailErrors } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { SendEmailData, SendEmailResponses, SendEmailErrors } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 a31ef7865..34a73e0be 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://api.postmarkapp.com` | (string & {}); +}; + export type SendEmailRequest = { /** * The sender email address. Must have a registered and confirmed Sender Signature. @@ -130,7 +134,3 @@ export type SendEmailResponses = { }; export type SendEmailResponse2 = SendEmailResponses[keyof SendEmailResponses]; - -export type ClientOptions = { - baseUrl: `${string}://api.postmarkapp.com` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 abeb3e1f8..ce899130e 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/types.gen.ts index 47a6dbbce..4d911cbe3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 6293e99d6..159ddeb7a 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/types.gen.ts index 47a6dbbce..4d911cbe3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 5f3be6607..452f08b23 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 47a6dbbce..4d911cbe3 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: string; -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 8e5659281..d5b1bcc1d 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/types.gen.ts index 47a6dbbce..4d911cbe3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: string; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client.gen.ts index 84e402e93..aadb5db4a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: '/v1' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 7e1ba4007..c3fcf5dff 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}/v1` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}/v1` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 85dba01eb..ca0a2a79e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://foo.com` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://foo.com` | (string & {}); -}; 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 53f8b2177..fd7b9d4cc 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://foo.com/v1' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 43d939745..b54728320 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'https://foo.com/v1' | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: 'https://foo.com/v1' | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 9db142760..127185a83 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: string; +}; + export type FooRead = BarRead & { readonly foo?: string; }; @@ -55,7 +59,3 @@ export type PostFooReadResponses = { }; export type PostFooReadResponse = PostFooReadResponses[keyof PostFooReadResponses]; - -export type ClientOptions = { - baseUrl: string; -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 d90f5b3af..2a149e830 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: string; }; @@ -9,7 +13,3 @@ export type Bar = Foo & {}; export type Baz = Foo & { bar: string; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 d67d3d123..4452f8fca 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: string; [key: string]: unknown | string; @@ -17,7 +21,3 @@ export type Baz = Foo & { export type Qux = { [key: string]: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 1097aeb99..d08207101 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: { [key: string]: unknown; }; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4ac068762..22248bd72 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: Array; }; export type Bar = string; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 6a8c31d0a..d998d02b5 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = Array<{ foo?: string; bar?: string; @@ -10,7 +14,3 @@ export type Foo = Array<{ foo?: string; bar?: string; }>; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 d0712e097..0c52381d2 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/types.gen.ts index a1b061174..5e6e1ffec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body: string; path?: never; @@ -15,7 +19,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/types.gen.ts index 54cfcc64e..0dd627bfc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-PascalCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/types.gen.ts index a29cd8ba6..038783521 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-camelCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type clientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type getFooResponses = { }; export type getFooResponse = getFooResponses[keyof getFooResponses]; - -export type clientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/types.gen.ts index ef766fce0..d30a3e951 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-preserve/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type getFooResponses = { }; export type getFooResponse = getFooResponses[keyof getFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/types.gen.ts index 954c678b2..89b79fffe 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/case-snake_case/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type client_options = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type get_foo_responses = { }; export type get_foo_response = get_foo_responses[keyof get_foo_responses]; - -export type client_options = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/types.gen.ts index 492b157bf..87f3a1faf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/components-request-bodies/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * Foo */ @@ -23,7 +27,3 @@ export type PostFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/types.gen.ts index 908d5cbec..97bd27233 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-binary/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -25,7 +29,3 @@ export type GetBarResponses = { }; export type GetBarResponse = GetBarResponses[keyof GetBarResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 f9331f0a1..0d9a49b3f 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 a2e7d5433..71bb11304 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseURL: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 3bd1045c3..517394ec6 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { id: string; }; @@ -61,7 +65,3 @@ export type BazUnion = { }; export type QuxExtend = FooUnion; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a3d6081eb..902f48ad5 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ type?: 'Bar'; } & Bar) | ({ @@ -26,7 +30,3 @@ export type Quuz = ({ } & Baz) | ({ type?: 'non-ascii'; } & Spæcial); - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 885b1c7d1..5fc5875d4 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ foo: 'one' | 'two'; } & Bar) | ({ @@ -19,7 +23,3 @@ export type Baz = { export type Spæcial = { foo?: 'four'; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 73005d217..7637bb05f 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ type: 'Bar'; } & Bar) | ({ @@ -26,7 +30,3 @@ export type Quuz = ({ } & Baz) | ({ type: 'non-ascii'; } & Spæcial); - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 db360dbbd..076177775 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: "foo'bar" | 'foo"bar'; }; export type Bar = "foo'bar" | 'foo"bar'; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 5ae81db36..6e877c00f 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { type?: TypeEnum; }; @@ -10,7 +14,3 @@ export const TypeEnum = { } as const; export type TypeEnum = typeof TypeEnum[keyof typeof TypeEnum]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 980626acc..ba7939b4f 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { type?: TypeEnum; }; @@ -8,7 +12,3 @@ export enum TypeEnum { FOO = 'foo', BAR = 'bar' } - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c1d043ba0..93dd5188f 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { type?: TypeEnum; }; export type TypeEnum = 'foo' | 'bar'; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 ed1eac27a..59d8a1055 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { 110: '1-10', 1120: '11-20' @@ -50,7 +54,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a0ada44fc..14a3b5383 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1_10': '1-10', '11_20': '11-20' @@ -50,7 +54,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 6c76ad876..439b40170 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { 110: '1-10', 1120: '11-20' @@ -50,7 +54,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a3452042d..436e55f83 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1-10': '1-10', '11-20': '11-20' @@ -49,7 +53,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 b4fdbac56..976eb7216 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1-10': '1-10', '11-20': '11-20' @@ -50,7 +54,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 30d55e299..c34b8edc9 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1_10': '1-10', '11_20': '11-20' @@ -50,7 +54,3 @@ export const Arrays = { } as const; export type Arrays = typeof Arrays[keyof typeof Arrays]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 d8b9e50d1..7f0916345 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { _110 = '1-10', _1120 = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c25efe013..72d21c8b5 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { '1_10' = '1-10', '11_20' = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 48930e998..ae4406721 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { _110 = '1-10', _1120 = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c99c71642..7b43908d9 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const enum _110 { _110 = '1-10', _1120 = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 95af7e0f2..a4169a3d5 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { '1-10' = '1-10', '11-20' = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 ece8dbc8d..c668186a7 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { '1_10' = '1-10', '11_20' = '11-20' @@ -33,7 +37,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 7c6cf43ce..7bbcad881 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type _110 = '1-10' | '11-20'; export type MyFoo = 'myFoo' | 'myBar'; @@ -17,7 +21,3 @@ export type Arrays = [ ] | [ 'baz' ]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 0f113e601..49d10ce0f 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = 'foo' | 'bar' | null; export type Bar = 'foo' | 'bar'; export type Baz = 'foo' | 'bar'; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 29f6d3874..bf1605beb 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = string; export type PostFooData = { @@ -15,7 +19,3 @@ export type PostFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/external/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2ab40752d..8f041dff7 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,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type ExternalSchemaA = ExternalSharedExternalSharedModel; export type ExternalSchemaB = ExternalSharedExternalSharedModel; @@ -430,7 +434,3 @@ export type GetExternalPropertiesByIdResponses = { }; export type GetExternalPropertiesByIdResponse = GetExternalPropertiesByIdResponses[keyof GetExternalPropertiesByIdResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 3e8c2dc31..3fc476405 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, create, create2, create3 } from '../sdk.gen'; +import type { CreateData, Create2Data, Create3Data } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 095925019..51d54a06a 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { CreateData, CreateResponses, Create2Data, Create2Responses, Create3Data, Create3Responses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { CreateData, CreateResponses, Create2Data, Create2Responses, Create3Data, Create3Responses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 3b84b928c..fae694b9b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type CreateData = { body?: never; path?: never; @@ -41,7 +45,3 @@ export type Create3Responses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c8043dbaa..4c71cace9 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body?: never; path?: never; @@ -19,7 +23,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 c968befbc..809286633 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4639723fb..62af858b9 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type PostFooResponses = { */ default: unknown; }; - -export type ClientOptions = { - baseURL: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 c968befbc..809286633 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 7e5ae0357..d564215cf 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type PostFooResponses = { */ default: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts new file mode 100644 index 000000000..c5e0605a8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common.gen.ts @@ -0,0 +1,1104 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type HttpRequest, httpResource } from '@angular/common/http'; +import { Injectable, inject } from '@angular/core'; + +import { client } from '../client.gen'; +import type { Options } from '../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, GetApiVbyApiVersionSimpleOperationData, ApiVVersionODataControllerCountData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, DummyAData, DummyBData, CollectionFormatData, TypesData, UploadFileData, FileResponseData, ComplexTypesData, ComplexParamsData, MultipartResponseData, MultipartRequestData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData, ImportResponse, GetApiVbyApiVersionSimpleOperationResponse, ApiVVersionODataControllerCountResponse, PostCallWithOptionalParamResponse, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, TypesResponse, UploadFileResponse, FileResponseResponse, ComplexTypesResponse, ComplexParamsResponse, MultipartResponseResponse, NonAsciiæøåÆøÅöôêÊ字符串Response } from '../types.gen'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultServiceRequests { + 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 + }); + } +} + +export class ODataControllerServiceRequests { + public apiVVersionODataControllerCount(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple/$count', + ...options + }); + } +} + +export class VVersionServiceRequests { + oDataControllerService = new ODataControllerServiceRequests(); +} + +export class ApiServiceRequests { + vVersionService = new VVersionServiceRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleServiceRequests { + 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 + }); + } + apiService = new ApiServiceRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersServiceRequests { + 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 DescriptionsServiceRequests { + 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 DeprecatedServiceRequests { + /** + * @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 RequestBodyServiceRequests { + 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 FormDataServiceRequests { + 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 DefaultsServiceRequests { + 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 DuplicateServiceRequests { + 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 NoContentServiceRequests { + 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 ResponseServiceRequests { + 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 MultipleTags1ServiceRequests { + 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 MultipleTags2ServiceRequests { + 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 MultipleTags3ServiceRequests { + 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 CollectionFormatServiceRequests { + 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 TypesServiceRequests { + 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 UploadServiceRequests { + 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 FileResponseServiceRequests { + 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 ComplexServiceRequests { + 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 MultipartServiceRequests { + 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 HeaderServiceRequests { + 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 ErrorServiceRequests { + 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ÆøåÆøÅöôêÊServiceRequests { + 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 + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultServiceResources { + public export(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).export(opts) : undefined; + }); + } + + public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + }); + } + + public import(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).import(opts) : undefined; + }); + } + + public fooWow(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).fooWow(opts) : undefined; + }); + } + + public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; + }); + } +} + +export class ODataControllerServiceResources { + public apiVVersionODataControllerCount(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).apiService.vVersionService.oDataControllerService.apiVVersionODataControllerCount(opts) : undefined; + }); + } +} + +export class VVersionServiceResources { + oDataControllerService = new ODataControllerServiceResources(); +} + +export class ApiServiceResources { + vVersionService = new VVersionServiceResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleServiceResources { + public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; + }); + } + apiService = new ApiServiceResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersServiceResources { + public deleteFoo(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).deleteFoo(opts) : undefined; + }); + } + + public callWithParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; + }); + } + + public callWithWeirdParameterNames(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; + }); + } + + public getCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).getCallWithOptionalParam(opts) : undefined; + }); + } + + public postCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).postCallWithOptionalParam(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsServiceResources { + public callWithDescriptions(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DeprecatedServiceResources { + /** + * @deprecated + */ + public deprecatedCall(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DeprecatedServiceRequests).deprecatedCall(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class RequestBodyServiceResources { + public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(RequestBodyServiceRequests).postApiVbyApiVersionRequestBody(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FormDataServiceResources { + public postApiVbyApiVersionFormData(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FormDataServiceRequests).postApiVbyApiVersionFormData(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsServiceResources { + public callWithDefaultParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; + }); + } + + public callWithDefaultOptionalParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; + }); + } + + public callToTestOrderOfParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateServiceResources { + public duplicateName(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; + }); + } + + public duplicateName2(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; + }); + } + + public duplicateName3(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; + }); + } + + public duplicateName4(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentServiceResources { + public callWithNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; + }); + } + + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseServiceResources { + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } + + public callWithResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; + }); + } + + public callWithDuplicateResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; + }); + } + + public callWithResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1ServiceResources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2ServiceResources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3ServiceResources { + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatServiceResources { + public collectionFormat(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesServiceResources { + public types(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(TypesServiceRequests).types(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class UploadServiceResources { + public uploadFile(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(UploadServiceRequests).uploadFile(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FileResponseServiceResources { + public fileResponse(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FileResponseServiceRequests).fileResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexServiceResources { + public complexTypes(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; + }); + } + + public complexParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexServiceRequests).complexParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipartServiceResources { + public multipartResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartServiceRequests).multipartResponse(opts) : undefined; + }); + } + + public multipartRequest(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartServiceRequests).multipartRequest(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderServiceResources { + public callWithResultFromHeader(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorServiceResources { + public testErrorCode(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊServiceResources { + public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + }); + } + + /** + * Login User + */ + public putWithFormUrlEncoded(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : 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/@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 deleted file mode 100644 index 84312629c..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts +++ /dev/null @@ -1,607 +0,0 @@ -// 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 DefaultServiceRequests { - 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 ODataControllerServiceRequests { - public apiVVersionODataControllerCount(options?: Options): HttpRequest { - return (options?.client ?? client).requestOptions({ - responseStyle: 'data', - method: 'GET', - url: '/api/v{api-version}/simple/$count', - ...options - }); - } -} - -class VVersionServiceRequests { - oDataControllerService = new ODataControllerServiceRequests(); -} - -class ApiServiceRequests { - vVersionService = new VVersionServiceRequests(); -} - -@Injectable({ - providedIn: 'root' -}) -export class SimpleServiceRequests { - 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 - }); - } - apiService = new ApiServiceRequests(); -} - -@Injectable({ - providedIn: 'root' -}) -export class ParametersServiceRequests { - 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 DescriptionsServiceRequests { - 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 DeprecatedServiceRequests { - /** - * @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 RequestBodyServiceRequests { - 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 FormDataServiceRequests { - 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 DefaultsServiceRequests { - 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 DuplicateServiceRequests { - 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 NoContentServiceRequests { - 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 ResponseServiceRequests { - 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 MultipleTags1ServiceRequests { - 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 MultipleTags2ServiceRequests { - 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 MultipleTags3ServiceRequests { - 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 CollectionFormatServiceRequests { - 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 TypesServiceRequests { - 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 UploadServiceRequests { - 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 FileResponseServiceRequests { - 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 ComplexServiceRequests { - 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 MultipartServiceRequests { - 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 HeaderServiceRequests { - 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 ErrorServiceRequests { - 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ÆøåÆøÅöôêÊServiceRequests { - 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 deleted file mode 100644 index bd8a166a2..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts +++ /dev/null @@ -1,503 +0,0 @@ -// 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 { 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 DefaultServiceResources { - public export(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).export(opts) : undefined; - }); - } - - public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; - }); - } - - public import(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).import(opts) : undefined; - }); - } - - public fooWow(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).fooWow(opts) : undefined; - }); - } - - public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; - }); - } -} - -class ODataControllerServiceResources { - public apiVVersionODataControllerCount(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).apiService.vVersionService.oDataControllerService.apiVVersionODataControllerCount(opts) : undefined; - }); - } -} - -class VVersionServiceResources { - oDataControllerService = new ODataControllerServiceResources(); -} - -class ApiServiceResources { - vVersionService = new VVersionServiceResources(); -} - -@Injectable({ - providedIn: 'root' -}) -export class SimpleServiceResources { - public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; - }); - } - apiService = new ApiServiceResources(); -} - -@Injectable({ - providedIn: 'root' -}) -export class ParametersServiceResources { - public deleteFoo(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).deleteFoo(opts) : undefined; - }); - } - - public callWithParameters(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; - }); - } - - public callWithWeirdParameterNames(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; - }); - } - - public getCallWithOptionalParam(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).getCallWithOptionalParam(opts) : undefined; - }); - } - - public postCallWithOptionalParam(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).postCallWithOptionalParam(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DescriptionsServiceResources { - public callWithDescriptions(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DeprecatedServiceResources { - /** - * @deprecated - */ - public deprecatedCall(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DeprecatedServiceRequests).deprecatedCall(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class RequestBodyServiceResources { - public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(RequestBodyServiceRequests).postApiVbyApiVersionRequestBody(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class FormDataServiceResources { - public postApiVbyApiVersionFormData(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(FormDataServiceRequests).postApiVbyApiVersionFormData(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DefaultsServiceResources { - public callWithDefaultParameters(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; - }); - } - - public callWithDefaultOptionalParameters(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; - }); - } - - public callToTestOrderOfParams(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DuplicateServiceResources { - public duplicateName(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; - }); - } - - public duplicateName2(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; - }); - } - - public duplicateName3(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; - }); - } - - public duplicateName4(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class NoContentServiceResources { - public callWithNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; - }); - } - - public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ResponseServiceResources { - public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; - }); - } - - public callWithResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; - }); - } - - public callWithDuplicateResponses(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; - }); - } - - public callWithResponses(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags1ServiceResources { - public dummyA(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; - }); - } - - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags2ServiceResources { - public dummyA(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; - }); - } - - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags3ServiceResources { - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class CollectionFormatServiceResources { - public collectionFormat(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class TypesServiceResources { - public types(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(TypesServiceRequests).types(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class UploadServiceResources { - public uploadFile(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(UploadServiceRequests).uploadFile(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class FileResponseServiceResources { - public fileResponse(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(FileResponseServiceRequests).fileResponse(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ComplexServiceResources { - public complexTypes(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; - }); - } - - public complexParams(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ComplexServiceRequests).complexParams(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipartServiceResources { - public multipartResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipartServiceRequests).multipartResponse(opts) : undefined; - }); - } - - public multipartRequest(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipartServiceRequests).multipartRequest(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class HeaderServiceResources { - public callWithResultFromHeader(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ErrorServiceResources { - public testErrorCode(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class NonAsciiÆøåÆøÅöôêÊServiceResources { - public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; - }); - } - - /** - * Login User - */ - public putWithFormUrlEncoded(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : 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 950198e01..6b55ac80f 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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-class/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/index.ts index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index 17622c66b..1dfac4e45 100644 --- 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 @@ -1,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 index 7fddaa46d..63b7de2ac 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common.gen.ts new file mode 100644 index 000000000..14fa2efa1 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common.gen.ts @@ -0,0 +1,787 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type HttpRequest, httpResource } from '@angular/common/http'; + +import { client } from '../client.gen'; +import type { Options } from '../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, 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, ImportResponse, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationResponse, PostCallWithOptionalParamResponse, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, DummyAResponse, DummyBResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, TypesResponse, UploadFileResponse, FileResponseResponse, ComplexTypesResponse, MultipartResponseResponse, ComplexParamsResponse, NonAsciiæøåÆøÅöôêÊ字符串Response } from '../types.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 + }); +}; + +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/@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 deleted file mode 100644 index e7b3678ca..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts +++ /dev/null @@ -1,444 +0,0 @@ -// 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 deleted file mode 100644 index a6d4fdd5b..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts +++ /dev/null @@ -1,348 +0,0 @@ -// 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 index 950198e01..6b55ac80f 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/index.ts index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index 17622c66b..1dfac4e45 100644 --- 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 @@ -1,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 index 7fddaa46d..63b7de2ac 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/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 e28017eaf..7f92a6b23 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' })); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2d5985b31..91bd50dc5 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, BusinessGetData, BusinessGetResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, GetData, GetResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -30,7 +30,7 @@ class _HeyApiClient { } } -class Domains extends _HeyApiClient { +export class Domains extends _HeyApiClient { public get(options?: Options) { return (options?.client ?? this._client).get({ url: '/business/providers/domains', @@ -46,11 +46,11 @@ class Domains extends _HeyApiClient { } } -class Providers extends _HeyApiClient { +export class Providers extends _HeyApiClient { domains = new Domains({ client: this._client }); } -class Business extends _HeyApiClient { +export class Business extends _HeyApiClient { public get(options?: Options) { return (options?.client ?? this._client).get({ url: '/locations/businesses', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts index 3c9d90569..3f503a59d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'https://api.example.com/v1' | (string & {}); +}; + export type BusinessProvidersDomainsGetData = { body?: never; path?: never; @@ -79,7 +83,3 @@ export type GetResponses = { }; export type GetResponse = GetResponses[keyof GetResponses]; - -export type ClientOptions = { - baseUrl: 'https://api.example.com/v1' | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts index e28017eaf..7f92a6b23 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://api.example.com/v1' })); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 4ff334ff7..58f593d8a 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class Domains { +export class Domains { public static get(options?: Options) { return (options?.client ?? client).get({ url: '/business/providers/domains', @@ -41,7 +41,7 @@ class Domains { } } -class Providers { +export class Providers { static domains = Domains; } 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 3c9d90569..3f503a59d 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'https://api.example.com/v1' | (string & {}); +}; + export type BusinessProvidersDomainsGetData = { body?: never; path?: never; @@ -79,7 +83,3 @@ export type GetResponses = { }; export type GetResponse = GetResponses[keyof GetResponses]; - -export type ClientOptions = { - baseUrl: 'https://api.example.com/v1' | (string & {}); -}; 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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/@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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 4cf0ca9c4..2d511cf07 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -30,7 +30,7 @@ class _HeyApiClient { } } -class Bar extends _HeyApiClient { +export class Bar extends _HeyApiClient { public post(options?: Options) { return (options?.client ?? this._client).post({ url: '/foo/bar', @@ -46,7 +46,7 @@ class Bar extends _HeyApiClient { } } -class Foo extends _HeyApiClient { +export class Foo extends _HeyApiClient { public post(options?: Options) { return (options?.client ?? this._client).post({ url: '/foo', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/types.gen.ts index 4001df3e9..836288372 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts index 7190dd07b..778e50856 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,9 +11,9 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base', throwOnError: true })); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 6d229fd5d..c19230132 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 5c161731c..1f8bf6602 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,13 +1,14 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; -import { vPostFooData, vPostFooResponse } from './valibot.gen'; import * as v from 'valibot'; -import { postFooResponseTransformer } from './transformers.gen'; + +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; +import { vPostFooData, vPostFooResponse } from './valibot.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 cc9dcf841..ea991c983 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 @@ -2,12 +2,12 @@ import type { PostFooResponse } from './types.gen'; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = BigInt(data.foo.toString()); +export const postFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -export const postFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = BigInt(data.foo.toString()); return data; }; 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 ba800b837..87d807f95 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 @@ -1,5 +1,13 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + +export type TypeID = `${T}_${string}`; + +export type UserId = TypeID<'user'>; + export type Foo = { bar?: number; foo: bigint; @@ -26,11 +34,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type TypeID = `${T}_${string}`; - -export type UserId = TypeID<'user'>; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 9067c31ee..e6ec9cb52 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,12 +1,12 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { TDataShape, Options as Options2, Client } from './client'; +import { client } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; import type { PostFooData, PostFooResponses } from './types.gen'; import { zPostFooData, zPostFooResponse } from './zod.gen'; -import { postFooResponseTransformer } from './transformers.gen'; -import { client } from './client.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 cc9dcf841..ea991c983 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 @@ -2,12 +2,12 @@ import type { PostFooResponse } from './types.gen'; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = BigInt(data.foo.toString()); +export const postFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -export const postFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = BigInt(data.foo.toString()); return data; }; 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 ba800b837..87d807f95 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 @@ -1,5 +1,13 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + +export type TypeID = `${T}_${string}`; + +export type UserId = TypeID<'user'>; + export type Foo = { bar?: number; foo: bigint; @@ -26,11 +34,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type TypeID = `${T}_${string}`; - -export type UserId = TypeID<'user'>; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 21ae98a77..09a3a4b1f 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Baz = { baz?: string; }; @@ -106,7 +110,3 @@ export type PostFooWriteResponses = { }; export type PostFooWriteResponse = PostFooWriteResponses[keyof PostFooWriteResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 b73d450d0..68b3b8b10 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type FooReadWrite = BarRead & { foo?: string; }; @@ -89,7 +93,3 @@ export type PostFooWriteResponses = { }; export type PostFooWriteResponse = PostFooWriteResponses[keyof PostFooWriteResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (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 index e31c2880d..a19022118 100644 --- 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 @@ -1,9 +1,10 @@ // 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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, GetFooResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 index fe57f118d..cab3c7019 100644 --- 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +export const client = createClient(createConfig()); 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 index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index 353557eb6..95671b708 100644 --- 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 @@ -1,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 index 4001df3e9..836288372 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 127e25c29..353fd0b40 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationError, 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -194,7 +195,7 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions, Error> => { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions, Error> => { return { mutation: async (fnOptions) => { const { data } = await deleteFoo({ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/@pinia/colada/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 01f8e2d24..7d91375f4 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 6850887fc..75d351cb2 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 d45c1ce28..6895e3c7a 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 fda250e99..bd0030147 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 cc71b7997..2e9bb8e0b 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 4dfbf97a8..89d6c36e2 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 ade1691a2..015d0c241 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/react-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 d45c1ce28..6895e3c7a 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 c4d031451..0ecbef381 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/react-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 80cf0ec00..e28573f3a 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 df3b287f4..36484b5ca 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 bddcb34e9..0ce0192c4 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/solid-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 d45c1ce28..6895e3c7a 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 e150db91b..a2ba96f00 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/solid-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 392d84621..6bc30992c 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 c8e3b0f3f..2e10ae9ef 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 822ebb27d..911c37db3 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/svelte-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 d45c1ce28..6895e3c7a 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 e883dc537..e468d7e86 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/svelte-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 98f162beb..664941756 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 cbbcb26a7..8e51a85ec 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 c86860577..3b0e94261 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/vue-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 d45c1ce28..6895e3c7a 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 c21b03b97..d9efc6866 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/vue-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 463216f2d..bb9cf3b21 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; export type FooBarPutResponse = FooBarPutResponses[keyof FooBarPutResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 f7b237f6a..0078ac95d 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,8 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +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'; + export type RouteHandlers = { import: RouteHandler<{ Body: ImportData['body']; @@ -16,8 +17,8 @@ export type RouteHandlers = { Reply: GetApiVbyApiVersionSimpleOperationResponses; }>; deleteFoo: RouteHandler<{ - Headers: DeleteFooData['headers']; - Params: DeleteFooData['path']; + Headers: DeleteFooData3['headers']; + Params: DeleteFooData3['path']; }>; callWithDescriptions: RouteHandler<{ Querystring?: CallWithDescriptionsData['query']; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 7fddaa46d..63b7de2ac 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2040,7 +2044,3 @@ export type PutWithFormUrlEncodedData = { 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/security-api-key/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client.gen.ts index fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2b1dad28c..5e0213cae 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/types.gen.ts index 7cd25c229..41519aa51 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -27,7 +31,3 @@ export type GetBarResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 5f3be6607..452f08b23 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 579f645ec..f0896eeea 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 8e5659281..d5b1bcc1d 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/types.gen.ts index 579f645ec..f0896eeea 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 8e5659281..d5b1bcc1d 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/types.gen.ts index 579f645ec..f0896eeea 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 8e5659281..d5b1bcc1d 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/types.gen.ts index 579f645ec..f0896eeea 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client.gen.ts index 53f8b2177..fd7b9d4cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://foo.com/v1' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 02482e56a..d7a0ac461 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'https://foo.com/v1' | `${string}://${string}/v1` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: 'https://foo.com/v1' | `${string}://${string}/v1` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 9336baf5a..36c9e4679 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 @@ -2,16 +2,15 @@ import type { GetFooResponse } from './types.gen'; -const quxSchemaResponseTransformer = (data: any) => { - if (data.baz) { - data.baz = new Date(data.baz); - } +export const getFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -const bazSchemaResponseTransformer = (data: any) => { - data = quxSchemaResponseTransformer(data); - data.bar = new Date(data.bar); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = data.foo.map((item: any) => { + return barSchemaResponseTransformer(item); + }); return data; }; @@ -22,14 +21,15 @@ const barSchemaResponseTransformer = (data: any) => { return data; }; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = data.foo.map((item: any) => { - return barSchemaResponseTransformer(item); - }); +const bazSchemaResponseTransformer = (data: any) => { + data = quxSchemaResponseTransformer(data); + data.bar = new Date(data.bar); return data; }; -export const getFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const quxSchemaResponseTransformer = (data: any) => { + if (data.baz) { + data.baz = new Date(data.baz); + } return data; }; 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 e2bd16164..f3fe6fe4c 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: Array; }; @@ -40,7 +44,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 62f0dd462..dad31f0d0 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 @@ -2,6 +2,13 @@ import type { GetFooResponse } from './types.gen'; +export const getFooResponseTransformer = async (data: any): Promise => { + data = data.map((item: any) => { + return fooSchemaResponseTransformer(item); + }); + return data; +}; + const fooSchemaResponseTransformer = (data: any) => { if (data.foo) { data.foo = new Date(data.foo); @@ -14,10 +21,3 @@ const fooSchemaResponseTransformer = (data: any) => { } return data; }; - -export const getFooResponseTransformer = async (data: any): Promise => { - data = data.map((item: any) => { - return fooSchemaResponseTransformer(item); - }); - return data; -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/types.gen.ts index dfee23093..12991171f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: Date; bar?: Date | null; @@ -21,7 +25,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/types.gen.ts index 89be77eab..fd57de924 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -19,7 +23,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 6c839b35d..57871fe36 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type FooReadWrite = BarRead; export type FooRead = BarRead & { @@ -106,7 +110,3 @@ export type PostFooWriteResponses = { }; export type PostFooWriteResponse = PostFooWriteResponses[keyof PostFooWriteResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 b507475fd..28b3e9b1c 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 @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -export type Foo = unknown; - export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); }; + +export type Foo = unknown; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 d90f5b3af..2a149e830 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: string; }; @@ -9,7 +13,3 @@ export type Bar = Foo & {}; export type Baz = Foo & { bar: string; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts index 31ed4dfc7..f2bd4bfe8 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-true-any/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: string; [key: string]: any | string; @@ -17,7 +21,3 @@ export type Baz = Foo & { export type Qux = { [key: string]: any; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 d67d3d123..4452f8fca 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: string; [key: string]: unknown | string; @@ -17,7 +21,3 @@ export type Baz = Foo & { export type Qux = { [key: string]: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 1097aeb99..d08207101 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: { [key: string]: unknown; }; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4ac068762..22248bd72 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: Array; }; export type Bar = string; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 6a8c31d0a..d998d02b5 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = Array<{ foo?: string; bar?: string; @@ -10,7 +14,3 @@ export type Foo = Array<{ foo?: string; bar?: string; }>; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 d0712e097..0c52381d2 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/types.gen.ts index a1b061174..5e6e1ffec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body: string; path?: never; @@ -15,7 +19,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/types.gen.ts index 54cfcc64e..0dd627bfc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-PascalCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/types.gen.ts index a29cd8ba6..038783521 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-camelCase/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type clientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type getFooResponses = { }; export type getFooResponse = getFooResponses[keyof getFooResponses]; - -export type clientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/types.gen.ts index ef766fce0..d30a3e951 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-preserve/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type getFooResponses = { }; export type getFooResponse = getFooResponses[keyof getFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/types.gen.ts index 954c678b2..89b79fffe 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/case-snake_case/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type client_options = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * original name: 201 */ @@ -83,7 +87,3 @@ export type get_foo_responses = { }; export type get_foo_response = get_foo_responses[keyof get_foo_responses]; - -export type client_options = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 9e134c9a8..139e7bacc 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base'; +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { query?: never; url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; }; - -export type ClientOptions = { - baseURL: 'http://localhost:3000/base'; -}; 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 9ce1b2c40..37c40c5f1 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseURL: 'https://foo.com' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 e497b32cc..48d370098 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,9 +1,9 @@ // 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 { type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -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 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 430815c63..c7a2005ff 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client/index.js'; +import type { ClientOptions as ClientOptions2 } from './types.gen.js'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cea7f39ce..5556b3a70 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen.js'; +export type * from './types.gen.js'; 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 d265aed90..5bbd28da6 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,10 +1,10 @@ // 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.js'; import { client } from './client.gen.js'; +import { type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 e671e5b13..c1b190d6e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base'; +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { query?: never; url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; }; - -export type ClientOptions = { - baseUrl: 'http://localhost:3000/base'; -}; 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 ccd37e81c..cf9533810 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://foo.com' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 d7073900a..c5aadf7ee 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,9 +1,9 @@ // 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 { type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -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 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 8b954d012..b47036454 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client/index.js'; +import type { ClientOptions as ClientOptions2 } from './types.gen.js'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cea7f39ce..5556b3a70 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen.js'; +export type * from './types.gen.js'; 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 d3cddea8e..83aa4d60c 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,10 +1,10 @@ // 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.js'; import { client } from './client.gen.js'; +import { type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 e671e5b13..c1b190d6e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base'; +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { query?: never; url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; }; - -export type ClientOptions = { - baseUrl: 'http://localhost:3000/base'; -}; 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 ccd37e81c..cf9533810 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://foo.com' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 d7073900a..c5aadf7ee 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,9 +1,9 @@ // 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 { type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -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 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 8b954d012..b47036454 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client/index.js'; +import type { ClientOptions as ClientOptions2 } from './types.gen.js'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cea7f39ce..5556b3a70 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen.js'; +export type * from './types.gen.js'; 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 d3cddea8e..83aa4d60c 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,10 +1,10 @@ // 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.js'; import { client } from './client.gen.js'; +import { type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 9e134c9a8..139e7bacc 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base'; +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { query?: never; url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; }; - -export type ClientOptions = { - baseURL: 'http://localhost:3000/base'; -}; 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 9ce1b2c40..37c40c5f1 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseURL: 'https://foo.com' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 f46dd8f72..27214c60f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 10e25d871..ef6579a74 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 { type Composable, type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/clients/@hey-api/client-nuxt/default/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 10e25d871..ef6579a74 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 { type Composable, type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/clients/@hey-api/client-nuxt/sdk-client-optional/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 10e25d871..ef6579a74 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 { type Composable, type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/clients/@hey-api/client-nuxt/sdk-client-required/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 efb1bc19c..5b0fbf202 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,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -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 { type Composable, type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -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 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client.gen.ts index 430815c63..c7a2005ff 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client/index.js'; +import type { ClientOptions as ClientOptions2 } from './types.gen.js'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cea7f39ce..5556b3a70 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen.js'; +export type * from './types.gen.js'; 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 64929d7f0..fdd2a2839 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Composable, type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/clients/my-client/base-url-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/custom-client.gen.ts similarity index 50% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/custom-client.gen.ts index fe57f118d..5ce607744 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/client-custom/base-url-false/custom-client.gen.ts @@ -1,7 +1,8 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; + +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +12,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index fece3b1d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-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' -})); 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/base-url-number/custom-client.gen.ts similarity index 53% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-number/custom-client.gen.ts index 950198e01..54e7e77e4 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/base-url-number/custom-client.gen.ts @@ -1,7 +1,8 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; + +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +12,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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index fece3b1d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-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' -})); 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/client-custom/base-url-strict/custom-client.gen.ts similarity index 53% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-strict/custom-client.gen.ts index 950198e01..54e7e77e4 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/client-custom/base-url-strict/custom-client.gen.ts @@ -1,7 +1,8 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; + +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +12,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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 e671e5b13..c1b190d6e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base'; +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { query?: never; url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; }; - -export type ClientOptions = { - baseUrl: 'http://localhost:3000/base'; -}; 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/client-custom/base-url-string/custom-client.gen.ts similarity index 53% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/custom-client.gen.ts index ccd37e81c..e41b638d2 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/client-custom/base-url-string/custom-client.gen.ts @@ -1,7 +1,8 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; + +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +12,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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://foo.com' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/clients/client-custom/bundle/custom-client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/custom-client.gen.ts new file mode 100644 index 000000000..6b55ac80f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/bundle/custom-client.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..9f00d6a97 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,10 +1,10 @@ // 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'; +import { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import { client } from './custom-client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index fece3b1d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-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' -})); 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/client-custom/default/custom-client.gen.ts similarity index 53% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/custom-client.gen.ts index 950198e01..54e7e77e4 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/client-custom/default/custom-client.gen.ts @@ -1,7 +1,8 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; + +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +12,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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/clients/client-custom/default/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/default/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2c08590e2..0a7087517 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,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; -export type Options = ClientOptions & { +import { client } from './custom-client.gen'; +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'; + +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +114,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index fece3b1d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-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' -})); 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/client-custom/sdk-client-optional/custom-client.gen.ts similarity index 53% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-optional/custom-client.gen.ts index 950198e01..54e7e77e4 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/client-custom/sdk-client-optional/custom-client.gen.ts @@ -1,7 +1,8 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; + +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +12,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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2c08590e2..0a7087517 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,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; -export type Options = ClientOptions & { +import { client } from './custom-client.gen'; +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'; + +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +114,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index fece3b1d1..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-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' -})); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/custom-client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/custom-client.gen.ts new file mode 100644 index 000000000..54e7e77e4 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/sdk-client-required/custom-client.gen.ts @@ -0,0 +1,19 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from '@hey-api/custom-client'; + +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 248978c90..dba67f37e 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,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from '@hey-api/custom-client'; -export type Options = ClientOptions & { +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'; + +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -112,7 +113,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 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/custom.gen.ts similarity index 50% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/custom.gen.ts index 8c006c0d8..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/custom.gen.ts @@ -1,7 +1,7 @@ // 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 '@hey-api/custom-client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +export const client = createClient(createConfig()); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/custom.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/custom.gen.ts new file mode 100644 index 000000000..6b55ac80f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/custom.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/custom.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/custom.gen.ts new file mode 100644 index 000000000..6b55ac80f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/custom.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 e671e5b13..c1b190d6e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base'; +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { query?: never; url: '/api/v{api-version}/non-ascii-æøåÆØÅöôêÊ字符串'; }; - -export type ClientOptions = { - baseUrl: 'http://localhost:3000/base'; -}; 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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; 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/my-client/base-url-string/custom.gen.ts similarity index 52% rename from packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/client-custom/base-url-string/client.gen.ts rename to packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/custom.gen.ts index bdea4782e..cf9533810 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/my-client/base-url-string/custom.gen.ts @@ -1,7 +1,7 @@ // 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 '@hey-api/custom-client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://foo.com' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/custom.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/custom.gen.ts new file mode 100644 index 000000000..6b55ac80f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/custom.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..a0bd869cb 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,10 +1,10 @@ // 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'; +import { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import { client } from './custom.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index 950198e01..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/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 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({ - baseUrl: 'http://localhost:3000/base' -})); 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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/custom.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/custom.gen.ts new file mode 100644 index 000000000..6b55ac80f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/custom.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..a0bd869cb 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,10 +1,10 @@ // 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'; +import { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import { client } from './custom.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index 950198e01..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/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 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({ - baseUrl: 'http://localhost:3000/base' -})); 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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/custom.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/custom.gen.ts new file mode 100644 index 000000000..6b55ac80f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/custom.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..a0bd869cb 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,10 +1,10 @@ // 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'; +import { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; +import { client } from './custom.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 deleted file mode 100644 index 950198e01..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/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 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({ - baseUrl: 'http://localhost:3000/base' -})); 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 fbac79053..83305b41f 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,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/custom.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/custom.gen.ts new file mode 100644 index 000000000..6b55ac80f --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/custom.gen.ts @@ -0,0 +1,18 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; + +/** + * 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' +})); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 d7073900a..c5aadf7ee 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,9 +1,9 @@ // 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 { type TDataShape, type Options as Options2, 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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -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 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/components-request-bodies/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/components-request-bodies/index.ts index 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 492b157bf..87f3a1faf 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * Foo */ @@ -23,7 +27,3 @@ export type PostFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 1d08e66f1..2a6c26099 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 908d5cbec..97bd27233 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -25,7 +29,3 @@ export type GetBarResponses = { }; export type GetBarResponse = GetBarResponses[keyof GetBarResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 f9331f0a1..0d9a49b3f 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 a2e7d5433..71bb11304 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseURL: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 3bd1045c3..517394ec6 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { id: string; }; @@ -61,7 +65,3 @@ export type BazUnion = { }; export type QuxExtend = FooUnion; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a3d6081eb..902f48ad5 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ type?: 'Bar'; } & Bar) | ({ @@ -26,7 +30,3 @@ export type Quuz = ({ } & Baz) | ({ type?: 'non-ascii'; } & Spæcial); - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 885b1c7d1..5fc5875d4 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ foo: 'one' | 'two'; } & Bar) | ({ @@ -19,7 +23,3 @@ export type Baz = { export type Spæcial = { foo?: 'four'; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 73005d217..7637bb05f 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ type: 'Bar'; } & Bar) | ({ @@ -26,7 +30,3 @@ export type Quuz = ({ } & Baz) | ({ type: 'non-ascii'; } & Spæcial); - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 727f7529e..8ec65de2e 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 @@ -1,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * should not produce duplicate null */ export type WeirdEnum = '' | string | null; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 db360dbbd..076177775 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: "foo'bar" | 'foo"bar'; }; export type Bar = "foo'bar" | 'foo"bar'; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 643e6fcae..55c65c88e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { type?: FooEnum; }; @@ -79,7 +83,3 @@ export type PutFooResponses = { }; export type PutFooResponse = PutFooResponses[keyof PutFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 0679a5270..984824e60 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { type?: FooEnum; }; @@ -73,7 +77,3 @@ export type PutFooResponses = { }; export type PutFooResponse = PutFooResponses[keyof PutFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 9163b485e..11923fa03 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { type?: FooEnum; }; @@ -65,7 +69,3 @@ export type PutFooResponses = { }; export type PutFooResponse = PutFooResponses[keyof PutFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 5ff3b9a6e..6095fbb53 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { 110: '1-10', 1120: '11-20' @@ -54,7 +58,3 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4dbcdea88..9e0894fa2 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1_10': '1-10', '11_20': '11-20' @@ -54,7 +58,3 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 cfb777368..7755c78be 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { 110: '1-10', 1120: '11-20' @@ -54,7 +58,3 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 793b1b847..e678ceafc 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1-10': '1-10', '11-20': '11-20' @@ -53,7 +57,3 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 15405bb7c..51ef367b7 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1-10': '1-10', '11-20': '11-20' @@ -54,7 +58,3 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 6b4b9490b..331b1d4ec 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const _110 = { '1_10': '1-10', '11_20': '11-20' @@ -54,7 +58,3 @@ export type Arrays = typeof Arrays[keyof typeof Arrays]; export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c8965f281..17261bdc8 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { _110 = '1-10', _1120 = '11-20' @@ -37,7 +41,3 @@ export type Arrays = [ export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c97aa30dc..4dadefd72 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { '1_10' = '1-10', '11_20' = '11-20' @@ -37,7 +41,3 @@ export type Arrays = [ export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 b840a69cd..73e0c57a9 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { _110 = '1-10', _1120 = '11-20' @@ -37,7 +41,3 @@ export type Arrays = [ export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 690678694..18729b813 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export const enum _110 { _110 = '1-10', _1120 = '11-20' @@ -37,7 +41,3 @@ export type Arrays = [ export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a81c6479f..f9011b1e2 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { '1-10' = '1-10', '11-20' = '11-20' @@ -37,7 +41,3 @@ export type Arrays = [ export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a4ea1ca03..e74fd5c76 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export enum _110 { '1_10' = '1-10', '11_20' = '11-20' @@ -37,7 +41,3 @@ export type Arrays = [ export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 28d7af1d6..143540e0b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type _110 = '1-10' | '11-20'; export type MyFoo = 'myFoo' | 'myBar'; @@ -21,7 +25,3 @@ export type Arrays = [ export type MyFooRef = { foo?: Array; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 0f113e601..49d10ce0f 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 @@ -1,11 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = 'foo' | 'bar' | null; export type Bar = 'foo' | 'bar'; export type Baz = 'foo' | 'bar'; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 29f6d3874..bf1605beb 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = string; export type PostFooData = { @@ -15,7 +19,3 @@ export type PostFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/external/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 fb7cc6bd2..888125c02 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * External schema (A) */ @@ -466,7 +470,3 @@ export type GetExternalPropertiesByIdResponses = { }; export type GetExternalPropertiesByIdResponse = GetExternalPropertiesByIdResponses[keyof GetExternalPropertiesByIdResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 fdd55cedc..fcfd74a58 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses, PatchFooData, PatchFooResponses, PostFooData, PostFooResponses, PutFooData, PutFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, PatchFooData, PatchFooResponses, PostFooData, PostFooResponses, PutFooData, PutFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/types.gen.ts index 2df3499e6..5eee04adf 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body: string; headers: { @@ -72,7 +76,3 @@ export type PutFooResponses = { }; export type PutFooResponse = PutFooResponses[keyof PutFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 3e8c2dc31..3fc476405 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, create, create2, create3 } from '../sdk.gen'; +import type { CreateData, Create2Data, Create3Data } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 095925019..51d54a06a 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { CreateData, CreateResponses, Create2Data, Create2Responses, Create3Data, Create3Responses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { CreateData, CreateResponses, Create2Data, Create2Responses, Create3Data, Create3Responses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 3b84b928c..fae694b9b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type CreateData = { body?: never; path?: never; @@ -41,7 +45,3 @@ export type Create3Responses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 653bc66d0..ca352b24f 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * Reaction Rollup */ @@ -15,7 +19,3 @@ export type ReactionRollup = { eyes: number; rocket: number; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 52d79623a..437eada2f 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { bar: string; } & { @@ -9,7 +13,3 @@ export type Foo = { bar?: string; baz?: string; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 626485d0c..a007c1a31 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ bar: string; } | { @@ -9,7 +13,3 @@ export type Foo = ({ bar?: string; baz?: string; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 626485d0c..a007c1a31 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = ({ bar: string; } | { @@ -9,7 +13,3 @@ export type Foo = ({ bar?: string; baz?: string; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 bc6d278d9..fb2658a1b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = 'foo' | 'bar'; export type Bar = { @@ -9,7 +13,3 @@ export type Bar = { export type Baz = { [key in Foo]?: number; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c8043dbaa..4c71cace9 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body?: never; path?: never; @@ -19,7 +23,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 36d23bebd..e08eb99cc 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts +import { queryOptions, infiniteQueryOptions, type DefaultError, type InfiniteData, type UseMutationOptions } from '@tanstack/react-query'; + +import { client } from '../client.gen'; 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 } from '../client.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 08f5a8071..755d0d649 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses, PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/types.gen.ts index 71f2c1e40..d8c37a6ba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { page?: number | null; }; @@ -41,7 +45,3 @@ export type PostFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 c968befbc..809286633 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4639723fb..62af858b9 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type PostFooResponses = { */ default: unknown; }; - -export type ClientOptions = { - baseURL: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 c968befbc..809286633 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 7e5ae0357..d564215cf 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type PostFooResponses = { */ default: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c455f81b4..bea1260fc 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PostFooData = { body?: never; path?: never; @@ -20,7 +24,3 @@ export type PostFooResponses = { */ default: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a99c8e749..df7deafb0 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type PatternPropertiesTest = { id?: string; metadata?: MetadataObject; @@ -50,7 +54,3 @@ export type PostPatternTestResponses = { }; export type PostPatternTestResponse = PostPatternTestResponses[keyof PostPatternTestResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common.gen.ts new file mode 100644 index 000000000..c5e0605a8 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common.gen.ts @@ -0,0 +1,1104 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type HttpRequest, httpResource } from '@angular/common/http'; +import { Injectable, inject } from '@angular/core'; + +import { client } from '../client.gen'; +import type { Options } from '../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, GetApiVbyApiVersionSimpleOperationData, ApiVVersionODataControllerCountData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, CallWithParametersData, CallWithWeirdParameterNamesData, GetCallWithOptionalParamData, PostCallWithOptionalParamData, CallWithDescriptionsData, DeprecatedCallData, PostApiVbyApiVersionRequestBodyData, PostApiVbyApiVersionFormDataData, CallWithDefaultParametersData, CallWithDefaultOptionalParametersData, CallToTestOrderOfParamsData, DuplicateNameData, DuplicateName2Data, DuplicateName3Data, DuplicateName4Data, CallWithNoContentResponseData, CallWithResponseAndNoContentResponseData, CallWithResponseData, CallWithDuplicateResponsesData, CallWithResponsesData, DummyAData, DummyBData, CollectionFormatData, TypesData, UploadFileData, FileResponseData, ComplexTypesData, ComplexParamsData, MultipartResponseData, MultipartRequestData, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, PutWithFormUrlEncodedData, ImportResponse, GetApiVbyApiVersionSimpleOperationResponse, ApiVVersionODataControllerCountResponse, PostCallWithOptionalParamResponse, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, DummyAResponse, DummyBResponse, TypesResponse, UploadFileResponse, FileResponseResponse, ComplexTypesResponse, ComplexParamsResponse, MultipartResponseResponse, NonAsciiæøåÆøÅöôêÊ字符串Response } from '../types.gen'; + +@Injectable({ + providedIn: 'root' +}) +export class DefaultServiceRequests { + 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 + }); + } +} + +export class ODataControllerServiceRequests { + public apiVVersionODataControllerCount(options?: Options): HttpRequest { + return (options?.client ?? client).requestOptions({ + responseStyle: 'data', + method: 'GET', + url: '/api/v{api-version}/simple/$count', + ...options + }); + } +} + +export class VVersionServiceRequests { + oDataControllerService = new ODataControllerServiceRequests(); +} + +export class ApiServiceRequests { + vVersionService = new VVersionServiceRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleServiceRequests { + 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 + }); + } + apiService = new ApiServiceRequests(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersServiceRequests { + 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 DescriptionsServiceRequests { + 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 DeprecatedServiceRequests { + /** + * @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 RequestBodyServiceRequests { + 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 FormDataServiceRequests { + 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 DefaultsServiceRequests { + 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 DuplicateServiceRequests { + 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 NoContentServiceRequests { + 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 ResponseServiceRequests { + 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 MultipleTags1ServiceRequests { + 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 MultipleTags2ServiceRequests { + 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 MultipleTags3ServiceRequests { + 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 CollectionFormatServiceRequests { + 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 TypesServiceRequests { + 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 UploadServiceRequests { + 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 FileResponseServiceRequests { + 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 ComplexServiceRequests { + 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 MultipartServiceRequests { + 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 HeaderServiceRequests { + 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 ErrorServiceRequests { + 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ÆøåÆøÅöôêÊServiceRequests { + 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 + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultServiceResources { + public export(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).export(opts) : undefined; + }); + } + + public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; + }); + } + + public import(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).import(opts) : undefined; + }); + } + + public fooWow(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).fooWow(opts) : undefined; + }); + } + + public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultServiceRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; + }); + } +} + +export class ODataControllerServiceResources { + public apiVVersionODataControllerCount(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).apiService.vVersionService.oDataControllerService.apiVVersionODataControllerCount(opts) : undefined; + }); + } +} + +export class VVersionServiceResources { + oDataControllerService = new ODataControllerServiceResources(); +} + +export class ApiServiceResources { + vVersionService = new VVersionServiceResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class SimpleServiceResources { + public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; + }); + } + + public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; + }); + } + apiService = new ApiServiceResources(); +} + +@Injectable({ + providedIn: 'root' +}) +export class ParametersServiceResources { + public deleteFoo(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).deleteFoo(opts) : undefined; + }); + } + + public callWithParameters(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; + }); + } + + public callWithWeirdParameterNames(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; + }); + } + + public getCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).getCallWithOptionalParam(opts) : undefined; + }); + } + + public postCallWithOptionalParam(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ParametersServiceRequests).postCallWithOptionalParam(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DescriptionsServiceResources { + public callWithDescriptions(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DeprecatedServiceResources { + /** + * @deprecated + */ + public deprecatedCall(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DeprecatedServiceRequests).deprecatedCall(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class RequestBodyServiceResources { + public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(RequestBodyServiceRequests).postApiVbyApiVersionRequestBody(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FormDataServiceResources { + public postApiVbyApiVersionFormData(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FormDataServiceRequests).postApiVbyApiVersionFormData(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DefaultsServiceResources { + public callWithDefaultParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; + }); + } + + public callWithDefaultOptionalParameters(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; + }); + } + + public callToTestOrderOfParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class DuplicateServiceResources { + public duplicateName(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; + }); + } + + public duplicateName2(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; + }); + } + + public duplicateName3(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; + }); + } + + public duplicateName4(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NoContentServiceResources { + public callWithNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; + }); + } + + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ResponseServiceResources { + public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; + }); + } + + public callWithResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; + }); + } + + public callWithDuplicateResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; + }); + } + + public callWithResponses(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags1ServiceResources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags2ServiceResources { + public dummyA(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; + }); + } + + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipleTags3ServiceResources { + public dummyB(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class CollectionFormatServiceResources { + public collectionFormat(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class TypesServiceResources { + public types(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(TypesServiceRequests).types(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class UploadServiceResources { + public uploadFile(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(UploadServiceRequests).uploadFile(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class FileResponseServiceResources { + public fileResponse(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(FileResponseServiceRequests).fileResponse(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ComplexServiceResources { + public complexTypes(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; + }); + } + + public complexParams(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ComplexServiceRequests).complexParams(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class MultipartServiceResources { + public multipartResponse(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartServiceRequests).multipartResponse(opts) : undefined; + }); + } + + public multipartRequest(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(MultipartServiceRequests).multipartRequest(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class HeaderServiceResources { + public callWithResultFromHeader(options?: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class ErrorServiceResources { + public testErrorCode(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; + }); + } +} + +@Injectable({ + providedIn: 'root' +}) +export class NonAsciiÆøåÆøÅöôêÊServiceResources { + public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : undefined; + return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; + }); + } + + /** + * Login User + */ + public putWithFormUrlEncoded(options: () => Options | undefined) { + return httpResource(() => { + const opts = options ? options() : 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/@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 deleted file mode 100644 index 84312629c..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/requests.gen.ts +++ /dev/null @@ -1,607 +0,0 @@ -// 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 DefaultServiceRequests { - 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 ODataControllerServiceRequests { - public apiVVersionODataControllerCount(options?: Options): HttpRequest { - return (options?.client ?? client).requestOptions({ - responseStyle: 'data', - method: 'GET', - url: '/api/v{api-version}/simple/$count', - ...options - }); - } -} - -class VVersionServiceRequests { - oDataControllerService = new ODataControllerServiceRequests(); -} - -class ApiServiceRequests { - vVersionService = new VVersionServiceRequests(); -} - -@Injectable({ - providedIn: 'root' -}) -export class SimpleServiceRequests { - 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 - }); - } - apiService = new ApiServiceRequests(); -} - -@Injectable({ - providedIn: 'root' -}) -export class ParametersServiceRequests { - 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 DescriptionsServiceRequests { - 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 DeprecatedServiceRequests { - /** - * @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 RequestBodyServiceRequests { - 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 FormDataServiceRequests { - 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 DefaultsServiceRequests { - 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 DuplicateServiceRequests { - 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 NoContentServiceRequests { - 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 ResponseServiceRequests { - 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 MultipleTags1ServiceRequests { - 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 MultipleTags2ServiceRequests { - 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 MultipleTags3ServiceRequests { - 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 CollectionFormatServiceRequests { - 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 TypesServiceRequests { - 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 UploadServiceRequests { - 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 FileResponseServiceRequests { - 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 ComplexServiceRequests { - 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 MultipartServiceRequests { - 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 HeaderServiceRequests { - 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 ErrorServiceRequests { - 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ÆøåÆøÅöôêÊServiceRequests { - 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 deleted file mode 100644 index bd8a166a2..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/@angular/common/http/resources.gen.ts +++ /dev/null @@ -1,503 +0,0 @@ -// 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 { 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 DefaultServiceResources { - public export(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).export(opts) : undefined; - }); - } - - public patchApiVbyApiVersionNoTag(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).patchApiVbyApiVersionNoTag(opts) : undefined; - }); - } - - public import(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).import(opts) : undefined; - }); - } - - public fooWow(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).fooWow(opts) : undefined; - }); - } - - public getApiVbyApiVersionSimpleOperation(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultServiceRequests).getApiVbyApiVersionSimpleOperation(opts) : undefined; - }); - } -} - -class ODataControllerServiceResources { - public apiVVersionODataControllerCount(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).apiService.vVersionService.oDataControllerService.apiVVersionODataControllerCount(opts) : undefined; - }); - } -} - -class VVersionServiceResources { - oDataControllerService = new ODataControllerServiceResources(); -} - -class ApiServiceResources { - vVersionService = new VVersionServiceResources(); -} - -@Injectable({ - providedIn: 'root' -}) -export class SimpleServiceResources { - public deleteCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).deleteCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public getCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).getCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public headCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).headCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public optionsCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).optionsCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public patchCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).patchCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public postCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).postCallWithoutParametersAndResponse(opts) : undefined; - }); - } - - public putCallWithoutParametersAndResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(SimpleServiceRequests).putCallWithoutParametersAndResponse(opts) : undefined; - }); - } - apiService = new ApiServiceResources(); -} - -@Injectable({ - providedIn: 'root' -}) -export class ParametersServiceResources { - public deleteFoo(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).deleteFoo(opts) : undefined; - }); - } - - public callWithParameters(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).callWithParameters(opts) : undefined; - }); - } - - public callWithWeirdParameterNames(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).callWithWeirdParameterNames(opts) : undefined; - }); - } - - public getCallWithOptionalParam(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).getCallWithOptionalParam(opts) : undefined; - }); - } - - public postCallWithOptionalParam(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ParametersServiceRequests).postCallWithOptionalParam(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DescriptionsServiceResources { - public callWithDescriptions(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DescriptionsServiceRequests).callWithDescriptions(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DeprecatedServiceResources { - /** - * @deprecated - */ - public deprecatedCall(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DeprecatedServiceRequests).deprecatedCall(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class RequestBodyServiceResources { - public postApiVbyApiVersionRequestBody(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(RequestBodyServiceRequests).postApiVbyApiVersionRequestBody(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class FormDataServiceResources { - public postApiVbyApiVersionFormData(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(FormDataServiceRequests).postApiVbyApiVersionFormData(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DefaultsServiceResources { - public callWithDefaultParameters(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callWithDefaultParameters(opts) : undefined; - }); - } - - public callWithDefaultOptionalParameters(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callWithDefaultOptionalParameters(opts) : undefined; - }); - } - - public callToTestOrderOfParams(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DefaultsServiceRequests).callToTestOrderOfParams(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class DuplicateServiceResources { - public duplicateName(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName(opts) : undefined; - }); - } - - public duplicateName2(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName2(opts) : undefined; - }); - } - - public duplicateName3(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName3(opts) : undefined; - }); - } - - public duplicateName4(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(DuplicateServiceRequests).duplicateName4(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class NoContentServiceResources { - public callWithNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(NoContentServiceRequests).callWithNoContentResponse(opts) : undefined; - }); - } - - public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ResponseServiceResources { - public callWithResponseAndNoContentResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponseAndNoContentResponse(opts) : undefined; - }); - } - - public callWithResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponse(opts) : undefined; - }); - } - - public callWithDuplicateResponses(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithDuplicateResponses(opts) : undefined; - }); - } - - public callWithResponses(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ResponseServiceRequests).callWithResponses(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags1ServiceResources { - public dummyA(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; - }); - } - - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags2ServiceResources { - public dummyA(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyA(opts) : undefined; - }); - } - - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipleTags3ServiceResources { - public dummyB(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipleTags1ServiceRequests).dummyB(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class CollectionFormatServiceResources { - public collectionFormat(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(CollectionFormatServiceRequests).collectionFormat(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class TypesServiceResources { - public types(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(TypesServiceRequests).types(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class UploadServiceResources { - public uploadFile(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(UploadServiceRequests).uploadFile(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class FileResponseServiceResources { - public fileResponse(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(FileResponseServiceRequests).fileResponse(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ComplexServiceResources { - public complexTypes(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ComplexServiceRequests).complexTypes(opts) : undefined; - }); - } - - public complexParams(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ComplexServiceRequests).complexParams(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class MultipartServiceResources { - public multipartResponse(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipartServiceRequests).multipartResponse(opts) : undefined; - }); - } - - public multipartRequest(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(MultipartServiceRequests).multipartRequest(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class HeaderServiceResources { - public callWithResultFromHeader(options?: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(HeaderServiceRequests).callWithResultFromHeader(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class ErrorServiceResources { - public testErrorCode(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(ErrorServiceRequests).testErrorCode(opts) : undefined; - }); - } -} - -@Injectable({ - providedIn: 'root' -}) -export class NonAsciiÆøåÆøÅöôêÊServiceResources { - public nonAsciiæøåÆøÅöôêÊ字符串(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : undefined; - return opts ? inject(NonAsciiÆøåÆøÅöôêÊServiceRequests).nonAsciiæøåÆøÅöôêÊ字符串(opts) : undefined; - }); - } - - /** - * Login User - */ - public putWithFormUrlEncoded(options: () => Options | undefined) { - return httpResource(() => { - const opts = options ? options() : 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 950198e01..6b55ac80f 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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-class/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/index.ts index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index 17622c66b..1dfac4e45 100644 --- 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 @@ -1,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 index 4c755476d..28ad7b64b 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common.gen.ts new file mode 100644 index 000000000..14fa2efa1 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common.gen.ts @@ -0,0 +1,787 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { type HttpRequest, httpResource } from '@angular/common/http'; + +import { client } from '../client.gen'; +import type { Options } from '../sdk.gen'; +import type { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, FooWowData, ApiVVersionODataControllerCountData, GetApiVbyApiVersionSimpleOperationData, DeleteCallWithoutParametersAndResponseData, GetCallWithoutParametersAndResponseData, HeadCallWithoutParametersAndResponseData, OptionsCallWithoutParametersAndResponseData, PatchCallWithoutParametersAndResponseData, PostCallWithoutParametersAndResponseData, PutCallWithoutParametersAndResponseData, DeleteFooData3, 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, ImportResponse, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationResponse, PostCallWithOptionalParamResponse, CallWithNoContentResponseResponse, CallWithResponseAndNoContentResponseResponse, DummyAResponse, DummyBResponse, CallWithResponseResponse, CallWithDuplicateResponsesResponse, CallWithResponsesResponse, TypesResponse, UploadFileResponse, FileResponseResponse, ComplexTypesResponse, MultipartResponseResponse, ComplexParamsResponse, NonAsciiæøåÆøÅöôêÊ字符串Response } from '../types.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 + }); +}; + +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/@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 deleted file mode 100644 index e7b3678ca..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/requests.gen.ts +++ /dev/null @@ -1,444 +0,0 @@ -// 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 deleted file mode 100644 index a6d4fdd5b..000000000 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/@angular/common/http/resources.gen.ts +++ /dev/null @@ -1,348 +0,0 @@ -// 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 index 950198e01..6b55ac80f 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/index.ts index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index 17622c66b..1dfac4e45 100644 --- 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 @@ -1,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 index 4c755476d..28ad7b64b 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2d5985b31..91bd50dc5 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, BusinessGetData, BusinessGetResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, GetData, GetResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -30,7 +30,7 @@ class _HeyApiClient { } } -class Domains extends _HeyApiClient { +export class Domains extends _HeyApiClient { public get(options?: Options) { return (options?.client ?? this._client).get({ url: '/business/providers/domains', @@ -46,11 +46,11 @@ class Domains extends _HeyApiClient { } } -class Providers extends _HeyApiClient { +export class Providers extends _HeyApiClient { domains = new Domains({ client: this._client }); } -class Business extends _HeyApiClient { +export class Business extends _HeyApiClient { public get(options?: Options) { return (options?.client ?? this._client).get({ url: '/locations/businesses', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts index 133a54ab9..8952a736a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type BusinessProvidersDomainsGetData = { body?: never; path?: never; @@ -79,7 +83,3 @@ export type GetResponses = { }; export type GetResponse = GetResponses[keyof GetResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 4ff334ff7..58f593d8a 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { BusinessProvidersDomainsGetData, BusinessProvidersDomainsGetResponses, BusinessProvidersDomainsPostData, BusinessProvidersDomainsPostResponses, PutBusinessProvidersDomainsData, PutBusinessProvidersDomainsResponses, BusinessGetData, BusinessGetResponses, GetData, GetResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class Domains { +export class Domains { public static get(options?: Options) { return (options?.client ?? client).get({ url: '/business/providers/domains', @@ -41,7 +41,7 @@ class Domains { } } -class Providers { +export class Providers { static domains = Domains; } 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 133a54ab9..8952a736a 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type BusinessProvidersDomainsGetData = { body?: never; path?: never; @@ -79,7 +83,3 @@ export type GetResponses = { }; export type GetResponse = GetResponses[keyof GetResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 950198e01..6b55ac80f 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/@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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 4cf0ca9c4..2d511cf07 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -30,7 +30,7 @@ class _HeyApiClient { } } -class Bar extends _HeyApiClient { +export class Bar extends _HeyApiClient { public post(options?: Options) { return (options?.client ?? this._client).post({ url: '/foo/bar', @@ -46,7 +46,7 @@ class Bar extends _HeyApiClient { } } -class Foo extends _HeyApiClient { +export class Foo extends _HeyApiClient { public post(options?: Options) { return (options?.client ?? this._client).post({ url: '/foo', diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/types.gen.ts index 4001df3e9..836288372 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@hey-api/sdk/throwOnError/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts index 7190dd07b..778e50856 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,9 +11,9 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base', throwOnError: true })); 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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 6d229fd5d..c19230132 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 5c161731c..1f8bf6602 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,13 +1,14 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { PostFooData, PostFooResponses } from './types.gen'; -import { vPostFooData, vPostFooResponse } from './valibot.gen'; import * as v from 'valibot'; -import { postFooResponseTransformer } from './transformers.gen'; + +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; +import type { PostFooData, PostFooResponses } from './types.gen'; +import { vPostFooData, vPostFooResponse } from './valibot.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 cc9dcf841..ea991c983 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 @@ -2,12 +2,12 @@ import type { PostFooResponse } from './types.gen'; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = BigInt(data.foo.toString()); +export const postFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -export const postFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = BigInt(data.foo.toString()); return data; }; 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 ba800b837..87d807f95 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 @@ -1,5 +1,13 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + +export type TypeID = `${T}_${string}`; + +export type UserId = TypeID<'user'>; + export type Foo = { bar?: number; foo: bigint; @@ -26,11 +34,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type TypeID = `${T}_${string}`; - -export type UserId = TypeID<'user'>; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 9067c31ee..e6ec9cb52 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,12 +1,12 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; +import type { TDataShape, Options as Options2, Client } from './client'; +import { client } from './client.gen'; +import { postFooResponseTransformer } from './transformers.gen'; import type { PostFooData, PostFooResponses } from './types.gen'; import { zPostFooData, zPostFooResponse } from './zod.gen'; -import { postFooResponseTransformer } from './transformers.gen'; -import { client } from './client.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 cc9dcf841..ea991c983 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 @@ -2,12 +2,12 @@ import type { PostFooResponse } from './types.gen'; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = BigInt(data.foo.toString()); +export const postFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -export const postFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = BigInt(data.foo.toString()); return data; }; 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 ba800b837..87d807f95 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 @@ -1,5 +1,13 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + +export type TypeID = `${T}_${string}`; + +export type UserId = TypeID<'user'>; + export type Foo = { bar?: number; foo: bigint; @@ -26,11 +34,3 @@ export type PostFooResponses = { }; export type PostFooResponse = PostFooResponses[keyof PostFooResponses]; - -export type TypeID = `${T}_${string}`; - -export type UserId = TypeID<'user'>; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 7c3bc951c..2b25e622c 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Baz = { baz?: string; }; @@ -160,7 +164,3 @@ export type PutFooWriteResponses = { }; export type PutFooWriteResponse = PutFooWriteResponses[keyof PutFooWriteResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 ee224cabf..2660fdee6 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type FooReadWrite = BarRead & { foo?: string; }; @@ -136,7 +140,3 @@ export type PutFooWriteResponses = { }; export type PutFooWriteResponse = PutFooWriteResponses[keyof PutFooWriteResponses]; - -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 index e31c2880d..a19022118 100644 --- 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 @@ -1,9 +1,10 @@ // 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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, GetFooResponse, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, GetFooBarResponse, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 index fe57f118d..cab3c7019 100644 --- 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 @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +export const client = createClient(createConfig()); 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 index cc646f13a..c352c1047 100644 --- 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 @@ -1,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 index 353557eb6..95671b708 100644 --- 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 @@ -1,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 index 4001df3e9..836288372 100644 --- 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/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 127e25c29..353fd0b40 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { ExportData, PatchApiVbyApiVersionNoTagData, ImportData, ImportResponse, FooWowData, ApiVVersionODataControllerCountData, ApiVVersionODataControllerCountResponse, GetApiVbyApiVersionSimpleOperationData, GetApiVbyApiVersionSimpleOperationResponse, GetApiVbyApiVersionSimpleOperationError, 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, TypesResponse, UploadFileData, UploadFileResponse, FileResponseData, FileResponseResponse, ComplexTypesData, ComplexTypesResponse, MultipartResponseData, MultipartResponseResponse, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -194,7 +195,7 @@ export const putCallWithoutParametersAndResponseMutation = (options?: Partial>): UseMutationOptions, Error> => { +export const deleteFooMutation = (options?: Partial>): UseMutationOptions, Error> => { return { mutation: async (fnOptions) => { const { data } = await deleteFoo({ diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/@pinia/colada/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 01f8e2d24..7d91375f4 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 6850887fc..75d351cb2 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 fda250e99..bd0030147 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 cc71b7997..2e9bb8e0b 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 4dfbf97a8..89d6c36e2 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 ade1691a2..015d0c241 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/react-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 c4d031451..0ecbef381 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/react-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 80cf0ec00..e28573f3a 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 df3b287f4..36484b5ca 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 bddcb34e9..0ce0192c4 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/solid-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 e150db91b..a2ba96f00 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/solid-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 392d84621..6bc30992c 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 c8e3b0f3f..2e10ae9ef 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 822ebb27d..911c37db3 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/svelte-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 e883dc537..e468d7e86 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/svelte-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 98f162beb..664941756 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 cbbcb26a7..8e51a85ec 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,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +import { type Options, FooBazService, BarBazService } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 353557eb6..95671b708 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooData, GetFooResponses, GetFooBarData, GetFooBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -18,7 +18,7 @@ export type Options; }; -class BarService { +export class BarService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo/bar', @@ -34,7 +34,7 @@ class BarService { } } -class FooService { +export class FooService { public static post(options?: Options) { return (options?.client ?? client).post({ url: '/foo', 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/@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 c86860577..3b0e94261 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 @@ -1,10 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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 } from '../client.gen'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -207,8 +208,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client.gen.ts index f46dd8f72..27214c60f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/vue-query/axios/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 cac41b947..11a2d3aff 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -116,7 +116,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 83b5f6181..a4462c23b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 c21b03b97..d9efc6866 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 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'; +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 { 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, CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, CallWithResponsesData, CallWithResponsesResponse, CallWithResponsesError, CollectionFormatData, TypesData, UploadFileData, UploadFileResponse, FileResponseData, ComplexTypesData, MultipartResponseData, MultipartRequestData, ComplexParamsData, ComplexParamsResponse, CallWithResultFromHeaderData, TestErrorCodeData, NonAsciiæøåÆøÅöôêÊ字符串Data, NonAsciiæøåÆøÅöôêÊ字符串Response, PutWithFormUrlEncodedData } from '../types.gen'; export type QueryKey = [ Pick & { @@ -206,8 +207,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, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client.gen.ts index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = 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/vue-query/fetch/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/index.ts index cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 17622c66b..1dfac4e45 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,10 +1,10 @@ // 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 { type TDataShape, type Options as Options2, type Client, formDataBodySerializer, urlSearchParamsBodySerializer } from './client'; import { client } from './client.gen'; +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'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a @@ -113,7 +113,7 @@ export const putCallWithoutParametersAndResponse = (options: Options) => { +export const deleteFoo = (options: Options) => { return (options.client ?? client).delete({ url: '/api/v{api-version}/foo/{foo_param}/bar/{BarParam}', ...options 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/@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 463216f2d..bb9cf3b21 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -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 } from '../client.gen'; +import { type Options, getFoo, fooPost, fooPut, getFooBar, fooBarPost, fooBarPut } from '../sdk.gen'; +import type { GetFooData, FooPostData, FooPostResponse, FooPutData, FooPutResponse, GetFooBarData, FooBarPostData, FooBarPostResponse, FooBarPutData, FooBarPutResponse } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 30f73c51c..5558f1fec 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,10 +1,10 @@ // 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 type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, FooPostData, FooPostResponses, FooPutData, FooPutResponses, GetFooBarData, GetFooBarResponses, FooBarPostData, FooBarPostResponses, FooBarPutData, FooBarPutResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 4001df3e9..836288372 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -95,7 +99,3 @@ export type FooBarPutResponses = { }; 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/fastify/default/fastify.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/fastify/default/fastify.gen.ts index f7b237f6a..0078ac95d 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,8 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -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'; +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'; + export type RouteHandlers = { import: RouteHandler<{ Body: ImportData['body']; @@ -16,8 +17,8 @@ export type RouteHandlers = { Reply: GetApiVbyApiVersionSimpleOperationResponses; }>; deleteFoo: RouteHandler<{ - Headers: DeleteFooData['headers']; - Params: DeleteFooData['path']; + Headers: DeleteFooData3['headers']; + Params: DeleteFooData3['path']; }>; callWithDescriptions: RouteHandler<{ Querystring?: CallWithDescriptionsData['query']; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 4c755476d..28ad7b64b 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -2059,7 +2063,3 @@ export type PutWithFormUrlEncodedData = { 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/ref-type/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/ref-type/index.ts index 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 ec2aea840..1f0922044 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: Array<{ baz: Bar | null; @@ -25,7 +29,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 a40131f08..afabab20e 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: string; baz?: string; @@ -10,7 +14,3 @@ export type Bar = Foo & { foo: string; baz: string; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 2faa0ef99..ac23756f1 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: string; baz?: string; @@ -8,7 +12,3 @@ export type Foo = { export type Bar = Foo & { bar: number; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 2faa0ef99..ac23756f1 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: string; baz?: string; @@ -8,7 +12,3 @@ export type Foo = { export type Bar = Foo & { bar: number; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 1db5e5052..aadaa3065 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo?: 'foo'; bar?: 3.2; @@ -35,7 +39,3 @@ export type Foo = { stringInt64?: '-9223372036854775808'; stringUint64?: '18446744073709551615'; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2b1dad28c..5e0213cae 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/types.gen.ts index 7cd25c229..41519aa51 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -27,7 +31,3 @@ export type GetBarResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 5f3be6607..452f08b23 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 579f645ec..f0896eeea 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 8e5659281..d5b1bcc1d 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/types.gen.ts index 579f645ec..f0896eeea 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 8e5659281..d5b1bcc1d 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/types.gen.ts index 579f645ec..f0896eeea 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 8e5659281..d5b1bcc1d 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/types.gen.ts index 579f645ec..f0896eeea 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -13,7 +17,3 @@ export type GetFooResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client.gen.ts index 53f8b2177..fd7b9d4cc 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'https://foo.com/v1' })); 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 02482e56a..d7a0ac461 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'https://foo.com/v1' | `${string}://${string}/v1` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -15,7 +19,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: 'https://foo.com/v1' | `${string}://${string}/v1` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 40a25a497..b406d8bb9 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 ea6b3e42a..d3fe8ca92 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Range = { start: { line: number; @@ -521,7 +525,3 @@ export type EventSubscribeResponses = { }; export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscribeResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 1f0d8da6e..213e032f2 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 a360dc82e..e8552bf4d 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: `${string}://${string}` | (string & {}); +}; + export type Range = { start: { line: number; @@ -521,7 +525,3 @@ export type EventSubscribeResponses = { }; export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscribeResponses]; - -export type ClientOptions = { - baseURL: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 40a25a497..b406d8bb9 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 ea6b3e42a..d3fe8ca92 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Range = { start: { line: number; @@ -521,7 +525,3 @@ export type EventSubscribeResponses = { }; export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscribeResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 40a25a497..b406d8bb9 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { EventSubscribeData, EventSubscribeResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 ea6b3e42a..d3fe8ca92 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Range = { start: { line: number; @@ -521,7 +525,3 @@ export type EventSubscribeResponses = { }; export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscribeResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 ce345c77c..3bd270683 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Composable, Client, TDataShape } from './client'; -import type { EventSubscribeResponse, EventSubscribeData } from './types.gen'; +import type { Composable, TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { EventSubscribeResponse, EventSubscribeData } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a 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 a360dc82e..e8552bf4d 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseURL: `${string}://${string}` | (string & {}); +}; + export type Range = { start: { line: number; @@ -521,7 +525,3 @@ export type EventSubscribeResponses = { }; export type EventSubscribeResponse = EventSubscribeResponses[keyof EventSubscribeResponses]; - -export type ClientOptions = { - baseURL: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/index.ts @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts index 521723fb3..21f18eeea 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/string-with-format/types.gen.ts @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -export type Foo = { - foo?: Array; -}; - export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); }; + +export type Foo = { + foo?: Array; +}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 9336baf5a..36c9e4679 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 @@ -2,16 +2,15 @@ import type { GetFooResponse } from './types.gen'; -const quxSchemaResponseTransformer = (data: any) => { - if (data.baz) { - data.baz = new Date(data.baz); - } +export const getFooResponseTransformer = async (data: any): Promise => { + data = fooSchemaResponseTransformer(data); return data; }; -const bazSchemaResponseTransformer = (data: any) => { - data = quxSchemaResponseTransformer(data); - data.bar = new Date(data.bar); +const fooSchemaResponseTransformer = (data: any) => { + data.foo = data.foo.map((item: any) => { + return barSchemaResponseTransformer(item); + }); return data; }; @@ -22,14 +21,15 @@ const barSchemaResponseTransformer = (data: any) => { return data; }; -const fooSchemaResponseTransformer = (data: any) => { - data.foo = data.foo.map((item: any) => { - return barSchemaResponseTransformer(item); - }); +const bazSchemaResponseTransformer = (data: any) => { + data = quxSchemaResponseTransformer(data); + data.bar = new Date(data.bar); return data; }; -export const getFooResponseTransformer = async (data: any): Promise => { - data = fooSchemaResponseTransformer(data); +const quxSchemaResponseTransformer = (data: any) => { + if (data.baz) { + data.baz = new Date(data.baz); + } return data; }; 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 e2bd16164..f3fe6fe4c 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type Foo = { foo: Array; }; @@ -40,7 +44,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 c3a28994c..820d528e1 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 @@ -2,6 +2,13 @@ import type { GetFooResponse, NestedDateObjectResponse } from './types.gen'; +export const getFooResponseTransformer = async (data: any): Promise => { + data = data.map((item: any) => { + return fooSchemaResponseTransformer(item); + }); + return data; +}; + const fooSchemaResponseTransformer = (data: any) => { if (data.foo) { data.foo = new Date(data.foo); @@ -18,10 +25,8 @@ const fooSchemaResponseTransformer = (data: any) => { return data; }; -export const getFooResponseTransformer = async (data: any): Promise => { - data = data.map((item: any) => { - return fooSchemaResponseTransformer(item); - }); +export const nestedDateObjectResponseTransformer = async (data: any): Promise => { + data = nestedDateObjectSchemaResponseTransformer(data); return data; }; @@ -33,8 +38,3 @@ const nestedDateObjectSchemaResponseTransformer = (data: any) => { } return data; }; - -export const nestedDateObjectResponseTransformer = async (data: any): Promise => { - data = nestedDateObjectSchemaResponseTransformer(data); - return data; -}; 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 ab403042b..354c5b6e2 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + /** * Object with a nested date structure */ @@ -47,7 +51,3 @@ export type NestedDateObjectResponses = { }; export type NestedDateObjectResponse = NestedDateObjectResponses[keyof NestedDateObjectResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/types.gen.ts index 89be77eab..fd57de924 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -19,7 +23,3 @@ export type GetFooResponses = { }; export type GetFooResponse = GetFooResponses[keyof GetFooResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client.gen.ts index fe57f118d..cab3c7019 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 6f56a6430..5dc1a5f01 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type FooReadWrite = BarRead; export type FooRead = BarRead & { @@ -153,7 +157,3 @@ export type PutFooWriteResponses = { }; export type PutFooWriteResponse = PutFooWriteResponses[keyof PutFooWriteResponses]; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 b507475fd..28b3e9b1c 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 @@ -1,7 +1,7 @@ // This file is auto-generated by @hey-api/openapi-ts -export type Foo = unknown; - export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); }; + +export type Foo = unknown; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 36097cc14..248263eaf 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 @@ -1,9 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts -export type Foo = { - bar?: number | boolean | string; -}; - export type ClientOptions = { baseUrl: `${string}://${string}` | (string & {}); }; + +export type Foo = { + bar?: number | boolean | string; +}; 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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 e0db6ccda..b7bb7bda6 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 @@ -1,5 +1,11 @@ // This file is auto-generated by @hey-api/openapi-ts +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; + /** * # session.user_phone_callout_ringing * @@ -3304,9 +3310,3 @@ export type SessionRecordingStoppedWebhookRequest = { path?: never; query?: never; }; - -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; 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 2a7a9213e..57129af5d 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/angular-query-experimental'; -import type { GetFooData, GetBarData } from '../types.gen'; + import { client } from '../client.gen'; +import { type Options, getFoo, getBar } from '../sdk.gen'; +import type { GetFooData, GetBarData } from '../types.gen'; export type QueryKey = [ Pick & { 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 39a86f05a..cebab9b44 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/react-query'; -import type { GetFooData, GetBarData } from '../types.gen'; + import { client } from '../client.gen'; +import { type Options, getFoo, getBar } from '../sdk.gen'; +import type { GetFooData, GetBarData } from '../types.gen'; export type QueryKey = [ Pick & { 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 ae71709ec..0fc4ed606 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/solid-query'; -import type { GetFooData, GetBarData } from '../types.gen'; + import { client } from '../client.gen'; +import { type Options, getFoo, getBar } from '../sdk.gen'; +import type { GetFooData, GetBarData } from '../types.gen'; export type QueryKey = [ Pick & { 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 291ad4e82..754fb9f4b 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/svelte-query'; -import type { GetFooData, GetBarData } from '../types.gen'; + import { client } from '../client.gen'; +import { type Options, getFoo, getBar } from '../sdk.gen'; +import type { GetFooData, GetBarData } from '../types.gen'; export type QueryKey = [ Pick & { 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 0c5ff38a7..0540b93db 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 @@ -1,9 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import { type Options, getFoo, getBar } from '../sdk.gen'; import { queryOptions } from '@tanstack/vue-query'; -import type { GetFooData, GetBarData } from '../types.gen'; + import { client } from '../client.gen'; +import { type Options, getFoo, getBar } from '../sdk.gen'; +import type { GetFooData, GetBarData } from '../types.gen'; export type QueryKey = [ Pick & { 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 fe57f118d..cab3c7019 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 ClientOptions as DefaultClientOptions, type Config, createClient, createConfig } from './client'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,6 +11,6 @@ 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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig()); +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 cc646f13a..c352c1047 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,4 +1,4 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; 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 2b1dad28c..5e0213cae 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,10 +1,10 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { Options as ClientOptions, Client, TDataShape } from './client'; -import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; +import type { TDataShape, Options as Options2, Client } from './client'; import { client } from './client.gen'; +import type { GetFooData, GetFooResponses, GetBarData, GetBarResponses } from './types.gen'; -export type Options = ClientOptions & { +export type Options = Options2 & { /** * You can provide a client instance returned by `createClient()` instead of * individual options. This might be also useful if you want to implement a diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/types.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/types.gen.ts index 7cd25c229..41519aa51 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/types.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/types.gen.ts @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: `${string}://${string}` | (string & {}); +}; + export type GetFooData = { body?: never; path?: never; @@ -27,7 +31,3 @@ export type GetBarResponses = { */ 200: unknown; }; - -export type ClientOptions = { - baseUrl: `${string}://${string}` | (string & {}); -}; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/index.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/index.ts.snap index 0339b6e31..b43a5238d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/index.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/index.ts.snap @@ -1,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * from './types.gen'; diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/types.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/types.gen.ts.snap index 7ddcc37be..10f6cc410 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/types.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3-types-PascalCase/types.gen.ts.snap @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -1987,7 +1991,3 @@ export type PutWithFormUrlEncodedData = { 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__/test/generated/v3_no_index/client.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client.gen.ts.snap index 950198e01..6b55ac80f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client.gen.ts.snap @@ -1,7 +1,7 @@ // 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'; +import { type ClientOptions, type Config, createClient, createConfig } from './client'; +import type { ClientOptions as ClientOptions2 } from './types.gen'; /** * The `createClientConfig()` function will be called on client initialization @@ -11,8 +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?: Config) => Config & T>; +export type CreateClientConfig = (override?: Config) => Config & T>; -export const client = createClient(createConfig({ +export const client = createClient(createConfig({ baseUrl: 'http://localhost:3000/base' })); 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 7ddcc37be..10f6cc410 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -1987,7 +1991,3 @@ export type PutWithFormUrlEncodedData = { 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__/test/generated/v3_types/index.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_types/index.ts.snap index 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 7ddcc37be..10f6cc410 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -1987,7 +1991,3 @@ export type PutWithFormUrlEncodedData = { 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__/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 0339b6e31..b43a5238d 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,3 +1,3 @@ // This file is auto-generated by @hey-api/openapi-ts -export * from './types.gen'; +export type * 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 7ddcc37be..10f6cc410 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 @@ -1,5 +1,9 @@ // This file is auto-generated by @hey-api/openapi-ts +export type ClientOptions = { + baseUrl: 'http://localhost:3000/base' | (string & {}); +}; + /** * Model with number-only name */ @@ -1987,7 +1991,3 @@ export type PutWithFormUrlEncodedData = { 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/custom/client/plugin.ts b/packages/openapi-ts-tests/main/test/custom/client/plugin.ts index fbac79053..83305b41f 100644 --- a/packages/openapi-ts-tests/main/test/custom/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/custom/client/plugin.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -17,16 +17,14 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Pick) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } @@ -45,7 +43,7 @@ export const defaultConfig: MyClientPlugin['Config'] = { name: __filename, }), config: clientDefaultConfig, - handler: clientPluginHandler as MyClientPlugin['Handler'], + handler: clientPluginHandler, name: __filename, }; diff --git a/packages/openapi-ts-tests/main/test/hey-api.ts b/packages/openapi-ts-tests/main/test/hey-api.ts new file mode 100644 index 000000000..7abbee273 --- /dev/null +++ b/packages/openapi-ts-tests/main/test/hey-api.ts @@ -0,0 +1,13 @@ +// @ts-ignore +import type { CreateClientConfig } from './client/client.gen'; + +// @ts-ignore +export const createClientConfig: CreateClientConfig = (config) => ({ + ...config, + // set default base url for requests + baseUrl: 'https://petstore3.swagger.io/api/v3', + // set default headers for requests + headers: { + Authorization: 'Bearer ', + }, +}); 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 dadb04614..4d13c24f2 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -3,7 +3,8 @@ import path from 'node:path'; // @ts-ignore import { customClientPlugin } from '@hey-api/custom-client/plugin'; -import { defineConfig } from '@hey-api/openapi-ts'; +// @ts-ignore +import { defineConfig, utils } from '@hey-api/openapi-ts'; import { getSpecsPath } from '../../utils'; // @ts-ignore @@ -33,18 +34,21 @@ export default defineConfig(() => { // }, path: path.resolve( getSpecsPath(), - '3.1.x', + '3.0.x', + 'circular.yaml', // 'invalid', // 'openai.yaml', // 'full.yaml', // 'opencode.yaml', // 'sdk-instance.yaml', - 'string-with-format.yaml', + // 'string-with-format.yaml', + // 'transformers.json', + // 'type-format.yaml', + // 'validators.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', + // path: 'scalar:@scalar/access-service', // path: 'hey-api/backend', // path: 'hey-api/backend?branch=main&version=1.0.0', // path: 'https://get.heyapi.dev/hey-api/backend?branch=main&version=1.0.0', @@ -69,15 +73,20 @@ export default defineConfig(() => { output: { // case: 'snake_case', clean: true, + fileName: { + // case: 'snake_case', + // name: '{{name}}.renamed', + // suffix: '.meh', + }, // format: 'prettier', - indexFile: false, + // indexFile: false, // lint: 'eslint', path: path.resolve(__dirname, 'generated', 'sample'), - // tsConfigPath: path.resolve( - // __dirname, - // 'tsconfig', - // 'tsconfig.nodenext.json', - // ), + tsConfigPath: path.resolve( + __dirname, + 'tsconfig', + 'tsconfig.nodenext.json', + ), }, parser: { filters: { @@ -109,9 +118,18 @@ export default defineConfig(() => { if (op.method === 'post' && op.path === '/search') { return true; } - return undefined; + return; }, }, + symbols: { + // getFilePath: (symbol) => { + // if (symbol.name) { + // return symbol.name[0]?.toLocaleLowerCase(); + // } + // return; + // // noop + // }, + }, }, pagination: { // keywords: ['aa'], @@ -146,20 +164,22 @@ export default defineConfig(() => { { // baseUrl: false, exportFromIndex: true, - // name: '@hey-api/client-fetch', + name: '@hey-api/client-fetch', // name: 'legacy/angular', + // runtimeConfigPath: path.resolve(__dirname, 'hey-api.ts'), + runtimeConfigPath: './src/hey-api.ts', // strictBaseUrl: true, // throwOnError: true, }, { // case: 'snake_case', // definitions: '你_snake_{{name}}', - enums: { - // case: 'PascalCase', - // constantsIgnoreNull: true, - // enabled: false, - mode: 'javascript', - }, + // enums: { + // // case: 'PascalCase', + // // constantsIgnoreNull: true, + // // enabled: false, + // mode: 'javascript', + // }, // errors: { // error: '他們_error_{{name}}', // name: '你們_errors_{{name}}', @@ -181,21 +201,34 @@ export default defineConfig(() => { asClass: true, // auth: false, // classNameBuilder: '{{name}}', + // classNameBuilder: '{{name}}Service', // classStructure: 'off', // client: false, // include... // instance: true, - // name: '@hey-api/sdk', + name: '@hey-api/sdk', // operationId: false, // params: 'experiment', // responseStyle: 'data', // transformer: '@hey-api/transformers', // transformer: true, - // validator: 'valibot', // validator: { // request: 'valibot', - // response: 'valibot', + // response: 'zod', // }, + '~hooks': { + symbols: { + // getFilePath: (symbol) => { + // if (symbol.name) { + // return utils.stringCase({ + // case: 'camelCase', + // value: symbol.name, + // }); + // } + // return; + // }, + }, + }, }, { // bigInt: true, @@ -218,7 +251,7 @@ export default defineConfig(() => { // mutationOptions: { // name: '{{name}}MO', // }, - // name: '@tanstack/react-query', + name: '@tanstack/react-query', // queryKeys: { // name: '{{name}}QK', // }, @@ -233,7 +266,7 @@ export default defineConfig(() => { if (op.method === 'post' && op.path === '/search') { return ['query']; } - return undefined; + return; }, isMutation() { // noop @@ -248,9 +281,9 @@ 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: 'PascalCase', // name: '{{name}}Data', @@ -262,6 +295,19 @@ export default defineConfig(() => { // webhooks: { // name: 'q{{name}}CoolWebhook', // }, + '~hooks': { + symbols: { + // getFilePath: (symbol) => { + // if (symbol.name) { + // return utils.stringCase({ + // case: 'camelCase', + // value: symbol.name, + // }); + // } + // return; + // }, + }, + }, }, { // case: 'snake_case', @@ -279,7 +325,7 @@ export default defineConfig(() => { }, exportFromIndex: true, metadata: true, - // name: 'zod', + name: 'zod', // requests: { // // case: 'SCREAMING_SNAKE_CASE', // // name: 'z{{name}}TestData', @@ -287,18 +333,33 @@ export default defineConfig(() => { // infer: 'E{{name}}DataZodType', // }, // }, - // responses: { - // // case: 'snake_case', - // // name: 'z{{name}}TestResponse', - // types: { - // infer: 'F{{name}}ResponseZodType', - // }, - // }, + responses: { + // case: 'snake_case', + // name: (name) => { + // if (name === 'complexTypes') { + // return 'z'; + // } + // return 'z{{name}}Response'; + // }, + // types: { + // infer: 'F{{name}}ResponseZodType', + // }, + }, types: { // infer: { // case: 'snake_case', // }, }, + '~hooks': { + symbols: { + // getFilePath: (symbol) => { + // if (symbol.name === 'z') { + // return 'complexService'; + // } + // return; + // }, + }, + }, }, { exportFromIndex: true, @@ -308,14 +369,15 @@ export default defineConfig(() => { { exportFromIndex: true, httpRequests: { - asClass: true, + // asClass: true, }, httpResources: { - asClass: true, + // asClass: true, }, // name: '@angular/common', }, { + exportFromIndex: true, // mutationOptions: '{{name}}Mutationssss', // name: '@pinia/colada', // queryOptions: { @@ -330,7 +392,7 @@ export default defineConfig(() => { if (op.method === 'post' && op.path === '/search') { return ['query']; } - return undefined; + return; }, }, }, diff --git a/packages/openapi-ts-tests/specs/3.0.x/circular.yaml b/packages/openapi-ts-tests/specs/3.0.x/circular.yaml new file mode 100644 index 000000000..211b0f00c --- /dev/null +++ b/packages/openapi-ts-tests/specs/3.0.x/circular.yaml @@ -0,0 +1,44 @@ +openapi: 3.0.4 +info: + title: OpenAPI 3.0.4 circular example + version: 1 +components: + schemas: + Foo: + type: object + properties: + quux: + $ref: '#/components/schemas/Quux' + Bar: + type: object + properties: + bar: + $ref: '#/components/schemas/Bar' + baz: + $ref: '#/components/schemas/Baz' + Baz: + type: object + properties: + quux: + $ref: '#/components/schemas/Quux' + Qux: + discriminator: + propertyName: type + mapping: + array: '#/components/schemas/Foo' + struct: '#/components/schemas/Corge' + oneOf: + - $ref: '#/components/schemas/Corge' + - $ref: '#/components/schemas/Foo' + Quux: + type: object + properties: + qux: + $ref: '#/components/schemas/Qux' + Corge: + type: object + properties: + baz: + type: array + items: + $ref: '#/components/schemas/Baz' diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/circular/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/circular/zod.gen.ts new file mode 100644 index 000000000..379f9a044 --- /dev/null +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/circular/zod.gen.ts @@ -0,0 +1,49 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import * as z from 'zod/v4-mini'; + +export const zBaz = z.object({ + get quux(): z.ZodMiniOptional { + return z.optional(zQuux); + } +}); + +export const zCorge = z.object({ + get baz(): z.ZodMiniOptional { + return z.optional(z.array(zBaz)); + } +}); + +export const zQux = z.union([ + z.intersection(z.object({ + type: z.literal('struct') + }), z.lazy(() => { + return zCorge; + })), + z.intersection(z.object({ + type: z.literal('array') + }), z.lazy(() => { + return zFoo; + })) +]); + +export const zQuux = z.object({ + get qux(): z.ZodMiniOptional { + return z.optional(zQux); + } +}); + +export const zFoo = z.object({ + quux: z.optional(zQuux) +}); + +export const zBar = z.object({ + get bar(): z.ZodMiniOptional { + return z.optional(z.lazy((): any => { + return zBar; + })); + }, + get baz(): z.ZodMiniOptional { + return z.optional(zBaz); + } +}); 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 cc4bc0b80..3b02520b7 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 @@ -779,7 +779,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/circular/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/circular/zod.gen.ts new file mode 100644 index 000000000..abc26f9e6 --- /dev/null +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/circular/zod.gen.ts @@ -0,0 +1,39 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +export const zBaz: z.AnyZodObject = z.object({ + quux: z.lazy(() => { + return zQuux; + }).optional() +}); + +export const zCorge = z.object({ + baz: z.array(zBaz).optional() +}); + +export const zQux: z.ZodTypeAny = z.union([ + z.object({ + type: z.literal('struct') + }).and(zCorge), + z.object({ + type: z.literal('array') + }).and(z.lazy(() => { + return zFoo; + })) +]); + +export const zQuux = z.object({ + qux: zQux.optional() +}); + +export const zFoo = z.object({ + quux: zQuux.optional() +}); + +export const zBar: z.AnyZodObject = z.object({ + bar: z.lazy(() => { + return zBar; + }).optional(), + baz: zBaz.optional() +}); diff --git a/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/circular/zod.gen.ts b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/circular/zod.gen.ts new file mode 100644 index 000000000..24c4880fa --- /dev/null +++ b/packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/circular/zod.gen.ts @@ -0,0 +1,49 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod/v4'; + +export const zBaz = z.object({ + get quux(): z.ZodOptional { + return z.optional(zQuux); + } +}); + +export const zCorge = z.object({ + get baz(): z.ZodOptional { + return z.optional(z.array(zBaz)); + } +}); + +export const zQux = z.union([ + z.object({ + type: z.literal('struct') + }).and(z.lazy(() => { + return zCorge; + })), + z.object({ + type: z.literal('array') + }).and(z.lazy(() => { + return zFoo; + })) +]); + +export const zQuux = z.object({ + get qux(): z.ZodOptional { + return z.optional(zQux); + } +}); + +export const zFoo = z.object({ + quux: z.optional(zQuux) +}); + +export const zBar = z.object({ + get bar(): z.ZodOptional { + return z.optional(z.lazy((): any => { + return zBar; + })); + }, + get baz(): z.ZodOptional { + return z.optional(zBaz); + } +}); 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 e7d8d2646..2241c0dbc 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 @@ -779,7 +779,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ 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 068645092..33b97c228 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 @@ -782,7 +782,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ 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 5c225d5ee..582c9ca06 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 @@ -11,6 +11,6 @@ export const zBar: z.AnyZodObject = z.object({ ]) }); -export const zFoo: z.AnyZodObject = z.object({ +export const zFoo = z.object({ foo: zBar }); 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 6050e6c5e..528fe0d3d 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 @@ -8,7 +8,7 @@ export const zBar: z.AnyZodObject = z.object({ })).optional() }); -export const zFoo: z.AnyZodObject = z.object({ +export const zFoo = z.object({ foo: zBar.optional() }); @@ -19,4 +19,4 @@ export const zQux: z.ZodTypeAny = z.lazy(() => { return zQux; }); -export const zBaz: z.ZodTypeAny = zQux; +export const zBaz = zQux; 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 ffd9033d7..63b277d7a 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 @@ -782,7 +782,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ diff --git a/packages/openapi-ts-tests/zod/v3/test/3.0.x.test.ts b/packages/openapi-ts-tests/zod/v3/test/3.0.x.test.ts index ed27c881f..d1cbd1460 100644 --- a/packages/openapi-ts-tests/zod/v3/test/3.0.x.test.ts +++ b/packages/openapi-ts-tests/zod/v3/test/3.0.x.test.ts @@ -42,6 +42,13 @@ for (const zodVersion of zodVersions) { description: 'generates correct array when items are oneOf array with single item', }, + { + config: createConfig({ + input: 'circular.yaml', + output: 'circular', + }), + description: 'generates circular schemas', + }, { config: createConfig({ input: 'enum-null.json', diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/circular/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/circular/zod.gen.ts new file mode 100644 index 000000000..c93fc275c --- /dev/null +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/circular/zod.gen.ts @@ -0,0 +1,49 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import * as z from 'zod/mini'; + +export const zBaz = z.object({ + get quux(): z.ZodMiniOptional { + return z.optional(zQuux); + } +}); + +export const zCorge = z.object({ + get baz(): z.ZodMiniOptional { + return z.optional(z.array(zBaz)); + } +}); + +export const zQux = z.union([ + z.intersection(z.object({ + type: z.literal('struct') + }), z.lazy(() => { + return zCorge; + })), + z.intersection(z.object({ + type: z.literal('array') + }), z.lazy(() => { + return zFoo; + })) +]); + +export const zQuux = z.object({ + get qux(): z.ZodMiniOptional { + return z.optional(zQux); + } +}); + +export const zFoo = z.object({ + quux: z.optional(zQuux) +}); + +export const zBar = z.object({ + get bar(): z.ZodMiniOptional { + return z.optional(z.lazy((): any => { + return zBar; + })); + }, + get baz(): z.ZodMiniOptional { + return z.optional(zBaz); + } +}); 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 821e28743..c862f31bb 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 @@ -779,7 +779,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/circular/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/circular/zod.gen.ts new file mode 100644 index 000000000..e73840e1d --- /dev/null +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/circular/zod.gen.ts @@ -0,0 +1,39 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod/v3'; + +export const zBaz: z.AnyZodObject = z.object({ + quux: z.lazy(() => { + return zQuux; + }).optional() +}); + +export const zCorge = z.object({ + baz: z.array(zBaz).optional() +}); + +export const zQux: z.ZodTypeAny = z.union([ + z.object({ + type: z.literal('struct') + }).and(zCorge), + z.object({ + type: z.literal('array') + }).and(z.lazy(() => { + return zFoo; + })) +]); + +export const zQuux = z.object({ + qux: zQux.optional() +}); + +export const zFoo = z.object({ + quux: zQuux.optional() +}); + +export const zBar: z.AnyZodObject = z.object({ + bar: z.lazy(() => { + return zBar; + }).optional(), + baz: zBaz.optional() +}); diff --git a/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/circular/zod.gen.ts b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/circular/zod.gen.ts new file mode 100644 index 000000000..50b4fafee --- /dev/null +++ b/packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/circular/zod.gen.ts @@ -0,0 +1,49 @@ +// This file is auto-generated by @hey-api/openapi-ts + +import { z } from 'zod'; + +export const zBaz = z.object({ + get quux(): z.ZodOptional { + return z.optional(zQuux); + } +}); + +export const zCorge = z.object({ + get baz(): z.ZodOptional { + return z.optional(z.array(zBaz)); + } +}); + +export const zQux = z.union([ + z.object({ + type: z.literal('struct') + }).and(z.lazy(() => { + return zCorge; + })), + z.object({ + type: z.literal('array') + }).and(z.lazy(() => { + return zFoo; + })) +]); + +export const zQuux = z.object({ + get qux(): z.ZodOptional { + return z.optional(zQux); + } +}); + +export const zFoo = z.object({ + quux: z.optional(zQuux) +}); + +export const zBar = z.object({ + get bar(): z.ZodOptional { + return z.optional(z.lazy((): any => { + return zBar; + })); + }, + get baz(): z.ZodOptional { + return z.optional(zBaz); + } +}); 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 dfb05e511..ed6c1cefc 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 @@ -779,7 +779,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ 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 db575e570..67cd9d8bf 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 @@ -782,7 +782,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ 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 0b40b33a2..15bdeb3e2 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 @@ -11,6 +11,6 @@ export const zBar: z.AnyZodObject = z.object({ ]) }); -export const zFoo: z.AnyZodObject = z.object({ +export const zFoo = z.object({ foo: zBar }); 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 81f594b60..7e6cc3c89 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 @@ -8,7 +8,7 @@ export const zBar: z.AnyZodObject = z.object({ })).optional() }); -export const zFoo: z.AnyZodObject = z.object({ +export const zFoo = z.object({ foo: zBar.optional() }); @@ -19,4 +19,4 @@ export const zQux: z.ZodTypeAny = z.lazy(() => { return zQux; }); -export const zBaz: z.ZodTypeAny = zQux; +export const zBaz = zQux; 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 a08796446..b74816cd8 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 @@ -782,7 +782,7 @@ export const zNestedAnyOfArraysNullable = z.object({ /** * This is a reusable parameter */ -export const zSimpleParameter = z.unknown(); +export const zSimpleParameter = z.string(); export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ z.object({ diff --git a/packages/openapi-ts-tests/zod/v4/test/3.0.x.test.ts b/packages/openapi-ts-tests/zod/v4/test/3.0.x.test.ts index ed27c881f..d1cbd1460 100644 --- a/packages/openapi-ts-tests/zod/v4/test/3.0.x.test.ts +++ b/packages/openapi-ts-tests/zod/v4/test/3.0.x.test.ts @@ -42,6 +42,13 @@ for (const zodVersion of zodVersions) { description: 'generates correct array when items are oneOf array with single item', }, + { + config: createConfig({ + input: 'circular.yaml', + output: 'circular', + }), + description: 'generates circular schemas', + }, { config: createConfig({ input: 'enum-null.json', diff --git a/packages/openapi-ts/src/config/output.ts b/packages/openapi-ts/src/config/output.ts index 702c59f74..423a1d340 100644 --- a/packages/openapi-ts/src/config/output.ts +++ b/packages/openapi-ts/src/config/output.ts @@ -1,23 +1,41 @@ import type { Config, UserConfig } from '../types/config'; +import { valueToObject } from './utils/config'; export const getOutput = (userConfig: UserConfig): Config['output'] => { - let output: Config['output'] = { - clean: true, - format: false, - indexFile: true, - lint: false, - path: '', - tsConfigPath: '', - }; - - if (typeof userConfig.output === 'string') { - output.path = userConfig.output; - } else { - output = { - ...output, - ...userConfig.output, - }; - } - - return output; + const output = valueToObject({ + defaultValue: { + clean: true, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, + path: '', + tsConfigPath: '', + }, + mappers: { + object: (fields, defaultValue) => ({ + ...fields, + fileName: valueToObject({ + defaultValue: { + ...(defaultValue.fileName as Extract< + typeof defaultValue.fileName, + Record + >), + }, + mappers: { + function: (name) => ({ name }), + string: (name) => ({ name }), + }, + value: fields.fileName, + }), + }), + string: (path) => ({ path }), + }, + value: userConfig.output, + }); + return output as Config['output']; }; diff --git a/packages/openapi-ts/src/generate/__tests__/class.test.ts b/packages/openapi-ts/src/generate/__tests__/class.test.ts index 81acd5b79..d68e87eb2 100644 --- a/packages/openapi-ts/src/generate/__tests__/class.test.ts +++ b/packages/openapi-ts/src/generate/__tests__/class.test.ts @@ -33,7 +33,17 @@ describe('generateLegacyClientClass', () => { }, name: 'AppClient', output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, diff --git a/packages/openapi-ts/src/generate/__tests__/core.test.ts b/packages/openapi-ts/src/generate/__tests__/core.test.ts index d5ba1f33b..8e0332a98 100644 --- a/packages/openapi-ts/src/generate/__tests__/core.test.ts +++ b/packages/openapi-ts/src/generate/__tests__/core.test.ts @@ -48,7 +48,17 @@ describe('generateLegacyCore', () => { }, name: 'AppClient', output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -190,7 +200,17 @@ describe('generateLegacyCore', () => { }, name: 'AppClient', output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -315,7 +335,17 @@ describe('generateLegacyCore', () => { }, name: 'AppClient', output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, diff --git a/packages/openapi-ts/src/generate/client.ts b/packages/openapi-ts/src/generate/client.ts index 4dae89d5b..ff0c15598 100644 --- a/packages/openapi-ts/src/generate/client.ts +++ b/packages/openapi-ts/src/generate/client.ts @@ -2,30 +2,24 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import type { IProject, ProjectRenderMeta } from '@hey-api/codegen-core'; 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 { Config } from '../types/config'; -import { splitNameAndExtension } from './file'; import { ensureDirSync, relativeModulePath } from './utils'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const getClientSrcPath = (name: string) => { - const pluginFilePathComponents = name.split(path.sep); - const clientSrcPath = pluginFilePathComponents - .slice(0, pluginFilePathComponents.length - 1) - .join(path.sep); - return clientSrcPath; -}; - /** * Returns path to the client module. When using client packages, this will be * simply the name of the package. When bundling a client, this will be a * relative path to the bundled client folder. + * + * @deprecated */ export const clientModulePath = ({ config, @@ -44,7 +38,7 @@ export const clientModulePath = ({ } if (path.isAbsolute(client.name)) { - const clientSrcPath = getClientSrcPath(client.name); + const clientSrcPath = path.dirname(client.name); const outputPath = path.resolve(config.output.path); return path.relative(outputPath, clientSrcPath).replace(/\\/g, '/'); } @@ -52,6 +46,27 @@ export const clientModulePath = ({ return client.name; }; +/** + * Returns absolute path to the client folder. This is hard-coded for now. + */ +export const clientFolderAbsolutePath = (config: Config): string => { + const client = getClientPlugin(config); + + if ('bundle' in client.config && client.config.bundle) { + // not proud of this one + const renamed: Map | undefined = + // @ts-expect-error + config._FRAGILE_CLIENT_BUNDLE_RENAMED; + return path.resolve( + config.output.path, + 'client', + `${renamed?.get('index') ?? 'index'}.ts`, + ); + } + + return client.name; +}; + /** * Recursively copies files and directories. * This is a PnP-compatible alternative to fs.cpSync that works with Yarn PnP's @@ -75,119 +90,91 @@ const copyRecursivePnP = (src: string, dest: string) => { } }; -const editFileContents = ({ +const renameFile = ({ filePath, - relativeImportSuffix, + project, + renamed, }: { filePath: string; - relativeImportSuffix?: string; + project: IProject; + renamed: Map; }) => { - let content = fs.readFileSync(filePath, 'utf8'); - - if (relativeImportSuffix) { - // Replace relative imports to append .js extension for ESM compatibility - // This handles patterns like: from './foo' -> from './foo.js' - // and: from '../bar' -> from '../bar.js' - content = content.replace( - /from\s+['"](\.\.?\/[^'"]*?)['"]/g, - (match, importPath) => { - // Don't add .js if it already has an extension - const lastSlashIndex = importPath.lastIndexOf('/'); - const fileName = - lastSlashIndex >= 0 - ? importPath.slice(lastSlashIndex + 1) - : importPath; - if (fileName.includes('.')) { - return match; - } - return `from '${importPath}${relativeImportSuffix}'`; - }, + const extension = path.extname(filePath); + const name = path.basename(filePath, extension); + const renamedName = project.fileName?.(name) || name; + if (renamedName !== name) { + const outputPath = path.dirname(filePath); + fs.renameSync( + filePath, + path.resolve(outputPath, `${renamedName}${extension}`), ); + renamed.set(name, renamedName); } - - const header = '// This file is auto-generated by @hey-api/openapi-ts\n\n'; - - content = `${header}${content}`; - - fs.writeFileSync(filePath, content, 'utf8'); }; -const renameAndEditFileContents = ({ - fileName, - outputPath, - shouldAppendJs, - shouldRename, +const replaceImports = ({ + filePath, + meta, + renamed, }: { - fileName: string; - outputPath: string; - shouldAppendJs: boolean; - shouldRename: boolean; + filePath: string; + meta: ProjectRenderMeta; + renamed: Map; }) => { - const { extension, name } = splitNameAndExtension(fileName); - let filePath = path.resolve(outputPath, fileName); - let suffix = ''; - - if (shouldRename) { - const infix = 'gen'; - suffix = `.${infix}`; - - // rename file: foo.ts -> foo.gen.ts - if (name !== 'index' && !name.endsWith(suffix)) { - const renamedFilePath = path.resolve( - outputPath, - [name, infix, extension].join('.'), - ); - fs.renameSync(filePath, renamedFilePath); - filePath = renamedFilePath; - } - } + let content = fs.readFileSync(filePath, 'utf8'); - if (shouldAppendJs) { - suffix = `${suffix}.js`; - } + content = content.replace( + /from\s+['"](\.\.?\/[^'"]*?)['"]/g, + (match, importPath) => { + const importIndex = match.indexOf(importPath); + const extension = path.extname(importPath); + const fileName = path.basename(importPath, extension); + const importDir = path.dirname(importPath); + const replacedName = + (renamed.get(fileName) ?? fileName) + + (meta?.moduleResolution === ts.ModuleResolutionKind.NodeNext + ? '.js' + : extension); + const replacedMatch = + match.slice(0, importIndex) + + [importDir, replacedName].filter(Boolean).join('/') + + match.slice(importIndex + importPath.length); + return replacedMatch; + }, + ); + + const header = '// This file is auto-generated by @hey-api/openapi-ts\n\n'; + + content = `${header}${content}`; - editFileContents({ - filePath, - relativeImportSuffix: suffix, - }); + fs.writeFileSync(filePath, content, 'utf8'); }; /** * Creates a `client` folder containing the same modules as the client package. */ export const generateClientBundle = ({ - legacy, + meta, outputPath, plugin, - tsConfig, + project, }: { - legacy?: boolean; + meta: ProjectRenderMeta; outputPath: string; plugin: DefinePlugin['Config']; - tsConfig: ts.ParsedCommandLine | null; -}): void => { + project?: IProject; +}): Map | undefined => { + const renamed = new Map(); + // copy Hey API clients to output const isHeyApiClientPlugin = plugin.name.startsWith('@hey-api/client-'); if (isHeyApiClientPlugin) { - const shouldAppendJs = - tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext; - // copy client core const coreOutputPath = path.resolve(outputPath, 'core'); ensureDirSync(coreOutputPath); const coreDistPath = path.resolve(__dirname, 'clients', 'core'); copyRecursivePnP(coreDistPath, coreOutputPath); - const coreFiles = fs.readdirSync(coreOutputPath); - for (const file of coreFiles) { - renameAndEditFileContents({ - fileName: file, - outputPath: coreOutputPath, - shouldAppendJs, - shouldRename: !legacy, - }); - } - // copy client bundle const clientOutputPath = path.resolve(outputPath, 'client'); ensureDirSync(clientOutputPath); @@ -199,22 +186,49 @@ export const generateClientBundle = ({ ); copyRecursivePnP(clientDistPath, clientOutputPath); + if (project) { + const copiedCoreFiles = fs.readdirSync(coreOutputPath); + for (const file of copiedCoreFiles) { + renameFile({ + filePath: path.resolve(coreOutputPath, file), + project, + renamed, + }); + } + + const copiedClientFiles = fs.readdirSync(clientOutputPath); + for (const file of copiedClientFiles) { + renameFile({ + filePath: path.resolve(clientOutputPath, file), + project, + renamed, + }); + } + } + + const coreFiles = fs.readdirSync(coreOutputPath); + for (const file of coreFiles) { + replaceImports({ + filePath: path.resolve(coreOutputPath, file), + meta, + renamed, + }); + } + const clientFiles = fs.readdirSync(clientOutputPath); for (const file of clientFiles) { - renameAndEditFileContents({ - fileName: file, - outputPath: clientOutputPath, - shouldAppendJs, - shouldRename: !legacy, + replaceImports({ + filePath: path.resolve(clientOutputPath, file), + meta, + renamed, }); } - return; + return renamed; } - let clientSrcPath = ''; - if (path.isAbsolute(plugin.name)) { - clientSrcPath = getClientSrcPath(plugin.name); - } + const clientSrcPath = path.isAbsolute(plugin.name) + ? path.dirname(plugin.name) + : undefined; // copy custom local client to output if (clientSrcPath) { @@ -242,4 +256,6 @@ export const generateClientBundle = ({ path.resolve(dirPath, file), ); } + + return; }; diff --git a/packages/openapi-ts/src/generate/file.ts b/packages/openapi-ts/src/generate/file.ts index 44939bc69..a928ba54c 100644 --- a/packages/openapi-ts/src/generate/file.ts +++ b/packages/openapi-ts/src/generate/file.ts @@ -3,7 +3,6 @@ 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'; @@ -16,6 +15,11 @@ type FileImportResult< name: Alias extends string ? Alias : Name; }; +/** + * TODO: remove, it's used by legacy plugins + * + * @deprecated + */ export class GeneratedFile { /** * Should the exports from this file be re-exported in the index barrel file? @@ -124,63 +128,6 @@ export class GeneratedFile { 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); } 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 801c3f38f..da5b2332a 100644 --- a/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts +++ b/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts @@ -32,7 +32,17 @@ describe('generateIndexFile', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, 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 e822389d9..a0db4be34 100644 --- a/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts +++ b/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts @@ -45,8 +45,17 @@ describe('generateLegacyOutput', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, format: 'prettier', + indexFile: true, + lint: false, path: './dist', + tsConfigPath: '', }, parser: { hooks: {}, diff --git a/packages/openapi-ts/src/generate/legacy/output.ts b/packages/openapi-ts/src/generate/legacy/output.ts index 55780953f..af675a5d1 100644 --- a/packages/openapi-ts/src/generate/legacy/output.ts +++ b/packages/openapi-ts/src/generate/legacy/output.ts @@ -1,5 +1,7 @@ import path from 'node:path'; +import type { ProjectRenderMeta } from '@hey-api/codegen-core'; + import type { OpenApi } from '../../openApi'; import { getClientPlugin } from '../../plugins/@hey-api/client-core/utils'; import type { Client } from '../../types/client'; @@ -67,12 +69,15 @@ export const generateLegacyOutput = async ({ 'bundle' in clientPlugin.config && clientPlugin.config.bundle ) { + const meta: ProjectRenderMeta = { + moduleResolution: tsConfig?.options.moduleResolution, + }; + generateClientBundle({ - legacy: true, + meta, outputPath, // @ts-expect-error plugin: clientPlugin, - tsConfig, }); } @@ -88,7 +93,7 @@ export const generateLegacyOutput = async ({ for (const name of config.pluginOrder) { const plugin = config.plugins[name]!; - const outputParts = (plugin.output ?? '').split('/'); + const outputParts = ((plugin.output as string) ?? '').split('/'); const outputDir = path.resolve( config.output.path, ...outputParts.slice(0, outputParts.length - 1), diff --git a/packages/openapi-ts/src/generate/output.ts b/packages/openapi-ts/src/generate/output.ts index ca53a6f96..3e6b44143 100644 --- a/packages/openapi-ts/src/generate/output.ts +++ b/packages/openapi-ts/src/generate/output.ts @@ -1,11 +1,10 @@ import fs from 'node:fs'; import path from 'node:path'; -import ts from 'typescript'; +import type { ProjectRenderMeta } from '@hey-api/codegen-core'; import type { IR } from '../ir/types'; import { getClientPlugin } from '../plugins/@hey-api/client-core/utils'; -import { tsc } from '../tsc'; import { generateClientBundle } from './client'; import { findTsConfigPath, loadTsConfig } from './tsConfig'; import { removeDirSync } from './utils'; @@ -20,16 +19,21 @@ export const generateOutput = async ({ context }: { context: IR.Context }) => { const tsConfig = loadTsConfig( findTsConfigPath(context.config.output.tsConfigPath), ); - const shouldAppendJs = - tsConfig?.options.moduleResolution === ts.ModuleResolutionKind.NodeNext; + + const meta: ProjectRenderMeta = { + moduleResolution: tsConfig?.options.moduleResolution, + }; const client = getClientPlugin(context.config); if ('bundle' in client.config && client.config.bundle) { - generateClientBundle({ + // not proud of this one + // @ts-expect-error + context.config._FRAGILE_CLIENT_BUNDLE_RENAMED = generateClientBundle({ + meta, outputPath, // @ts-expect-error plugin: client, - tsConfig, + project: context.gen, }); } @@ -37,59 +41,10 @@ export const generateOutput = async ({ context }: { context: IR.Context }) => { await plugin.run(); } - if (!context.config.dryRun) { - // TODO: delete old approach - const indexFile = context.createFile({ - id: '_index', - path: 'index', - }); - - // TODO: delete old approach - for (const file of Object.values(context.files)) { - const fileName = file.nameWithoutExtension(); - - if (fileName === indexFile.nameWithoutExtension()) { - continue; - } - - if ( - !file.isEmpty() && - file.exportFromIndex && - context.config.output.indexFile - ) { - let resolvedModule = indexFile.relativePathToFile({ - context, - id: file.id, - }); - if ( - shouldAppendJs && - (resolvedModule.startsWith('./') || resolvedModule.startsWith('../')) - ) { - if (resolvedModule === './client') { - resolvedModule = './client/index.js'; - } else { - resolvedModule = `${resolvedModule}.js`; - } - } - // TODO: parser - add export method for more granular control over - // what's exported so we can support named exports - indexFile.add(tsc.exportAllDeclaration({ module: resolvedModule })); - } - - file.write('\n\n', tsConfig); - } - - // TODO: delete old approach - if (!indexFile.isEmpty()) { - indexFile.write('\n', tsConfig); - } - - for (const file of context.gen.render({ - moduleResolution: tsConfig?.options.moduleResolution, - })) { - if (!file.content) continue; - const filePath = path.resolve(outputPath, file.path); - const dir = path.dirname(filePath); + for (const file of context.gen.render(meta)) { + const filePath = path.resolve(outputPath, file.path); + const dir = path.dirname(filePath); + if (!context.config.dryRun) { fs.mkdirSync(dir, { recursive: true }); fs.writeFileSync(filePath, file.content, { encoding: 'utf8' }); } diff --git a/packages/openapi-ts/src/generate/renderer.ts b/packages/openapi-ts/src/generate/renderer.ts index 212d69ae0..8f685efde 100644 --- a/packages/openapi-ts/src/generate/renderer.ts +++ b/packages/openapi-ts/src/generate/renderer.ts @@ -1,252 +1,354 @@ +import path from 'node:path'; + import type { - ICodegenBiMap, - ICodegenFile, - ICodegenImport, - ICodegenMeta, - ICodegenRenderer, + BiMap, + Binding, + File, + IProject, + ProjectRenderMeta, + Renderer, + Symbol, } from '@hey-api/codegen-core'; -import { replaceWrappedIds } from '@hey-api/codegen-core'; +import { createBinding, mergeBindings, renderIds } 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'; +const nodeBuiltins = new Set([ + 'buffer', + 'child_process', + 'cluster', + 'console', + 'constants', + 'crypto', + 'dgram', + 'dns', + 'domain', + 'events', + 'freelist', + 'fs', + 'http', + 'https', + 'module', + 'net', + 'os', + 'path', + 'process', + 'punycode', + 'querystring', + 'readline', + 'repl', + 'stream', + 'string_decoder', + 'timers', + 'tls', + 'tty', + 'url', + 'util', + 'v8', + 'vm', + 'worker_threads', + 'zlib', +]); - private ensureValidName(name: string): string { - return ensureValidIdentifier(name); - } +export class TypeScriptRenderer implements Renderer { + private addBinding({ + bindings, + file, + meta, + project, + symbol, + }: { + bindings: Map; + file: File; + meta?: ProjectRenderMeta; + project: IProject; + symbol: Symbol; + }): void { + if (!symbol.external && !project.symbols.hasValue(symbol.id)) { + return; + } - private getUniqueName( - base: string, - names: ICodegenBiMap, - ): string { - let index = 2; - let name = base; - while (names.hasValue(name)) { - name = `${base}${index}`; - index += 1; + const [symbolFile] = project.symbolIdToFiles(symbol.id); + if (!symbolFile) return; + + const modulePath = this.getBindingPath(file, symbolFile, meta); + const existing = bindings.get(modulePath); + const binding = createBinding({ + file, + modulePath, + symbol, + symbolFile, + }); + if (existing) { + mergeBindings(existing, binding); + bindings.set(modulePath, existing); + } else { + bindings.set(modulePath, binding); } - return name; } - private groupByKey( - file: ICodegenFile, - group: 'exports' | 'imports', - meta?: ICodegenMeta, - ): Map> { - const grouped = new Map>(); - - for (const value of file[group]) { - const shouldAppendJs = - meta?.moduleResolution === ts.ModuleResolutionKind.NodeNext; - const key = - typeof value.from === 'string' - ? value.from - : `${file.relativePathToFile(value.from)}${shouldAppendJs ? '.js' : ''}`; - if (!grouped.has(key)) { - grouped.set(key, []); + private getBindingPath( + currentFile: File, + symbolFile: File, + meta?: ProjectRenderMeta, + ): string { + if (!currentFile.path || !symbolFile.path) { + return ''; + } + if (symbolFile.external && !path.isAbsolute(symbolFile.path)) { + return symbolFile.path; + } + let relativePath = path.posix.relative( + path.posix.dirname( + currentFile.path.split(path.sep).join(path.posix.sep), // normalize to posix + ), + symbolFile.path.split(path.sep).join(path.posix.sep), // normalize to posix + ); + if (!relativePath.startsWith('.') && relativePath !== '') { + relativePath = `./${relativePath}`; + } + if (symbolFile.extension === '.ts') { + if (relativePath.endsWith(symbolFile.extension)) { + relativePath = relativePath.slice(0, -symbolFile.extension.length); + } + if (meta?.moduleResolution === ts.ModuleResolutionKind.NodeNext) { + relativePath += '.js'; + } else if (relativePath.endsWith('/index')) { + relativePath = relativePath.slice(0, -'/index'.length); } - grouped.get(key)!.push(value); } - - return grouped; + return relativePath; } - 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`, - ); + private getBodyLines(file: File, project: IProject): Array { + const lines: Array = []; + + for (const symbolId of file.symbols.body) { + const value = project.symbols.getValue(symbolId); + if (typeof value === 'string') { + lines.push(value); + } else if (value instanceof Array) { + for (const node of value) { + lines.push(tsNodeToString({ node, unescape: true })); + } + } else if (value !== undefined && value !== null) { + lines.push(tsNodeToString({ node: value as any, unescape: true })); } } - let body = results.join('\n'); - body = replaceWrappedIds(body, (symbolId) => - this.replacerFn({ file, headless: false, scope: 'file', symbolId }), - ); - return body; + + return lines; } - private renderExports(file: ICodegenFile, meta?: ICodegenMeta): string { - const grouped = this.groupByKey(file, 'exports', meta); - const statements: Array = []; + private getExportLines( + bindings: Map, + file: File, + project: IProject, + ): Array { + const lines: Array = []; - for (const [from, group] of grouped.entries()) { - const isTypeOnly = group.every( - (value) => - value.typeDefaultImport || - value.typeNamespaceImport || - value.names?.every((name) => value.typeNames?.includes(name)), - ); + for (const [from, value] of bindings.entries()) { + const specifiers: Array = []; + let namespaceBinding: string | undefined; + let isTypeOnly = false; - if (group.length === 1 && group[0]!.namespaceImport) { - const exportClause = - typeof group[0]!.namespaceImport === 'string' - ? ts.factory.createNamespaceExport( - tsc.identifier({ text: group[0]!.namespaceImport }), - ) - : undefined; - const node = ts.factory.createExportDeclaration( - undefined, - false, - exportClause, - tsc.stringLiteral({ isSingleQuote: true, text: from }), - ); - statements.push(tsNodeToString({ node })); - continue; - } + if (value.namespaceBinding !== undefined) { + if (typeof value.namespaceBinding === 'string') { + namespaceBinding = renderIds(value.namespaceBinding, (symbolId) => { + const symbol = project.symbols.get(symbolId); + return this.replacerFn({ file, project, symbol }); + }); + } + if (value.typeNamespaceBinding) { + isTypeOnly = true; + } + } else if (value.names && value.names.length > 0) { + if ( + value.names.every((name) => (value.typeNames ?? []).includes(name)) + ) { + isTypeOnly = true; + } - const namedSpecifiers: Array = []; - for (const value of group) { - for (const name of value.names ?? []) { + for (const name of value.names) { const alias = value.aliases?.[name]; - const specifier = - alias && alias !== name - ? ts.factory.createExportSpecifier( - false, - tsc.identifier({ text: name }), - tsc.identifier({ text: alias }), - ) - : ts.factory.createExportSpecifier( - false, - undefined, - tsc.identifier({ text: name }), - ); - namedSpecifiers.push(specifier); + let finalName = name; + let finalAlias: string | undefined; + if (alias && alias !== finalName) { + finalAlias = finalName; + finalName = alias; + } + finalName = renderIds(finalName, (symbolId) => { + const symbol = project.symbols.get(symbolId); + const name = this.replacerFn({ file, project, symbol }); + const [symbolFile] = project.symbolIdToFiles(symbolId); + const sourceName = symbolFile + ? symbolFile.resolvedNames.get(symbolId) + : undefined; + if (sourceName && sourceName !== name) { + // handle only simple imports for now + if (!finalAlias) { + finalAlias = sourceName; + } + } + return name; + }); + if (finalAlias) { + finalAlias = renderIds(finalAlias, (symbolId) => { + const symbol = project.symbols.get(symbolId); + return this.replacerFn({ file, project, symbol }); + }); + // remove redundant alias + if (finalAlias === finalName) { + finalAlias = undefined; + } + } + const specifier = ts.factory.createExportSpecifier( + isTypeOnly ? false : (value.typeNames?.includes(name) ?? false), + finalAlias ? tsc.identifier({ text: finalAlias }) : undefined, + tsc.identifier({ text: finalName }), + ); + specifiers.push(specifier); } } + const exportClause = namespaceBinding + ? ts.factory.createNamespaceExport( + tsc.identifier({ text: namespaceBinding }), + ) + : specifiers.length + ? ts.factory.createNamedExports(specifiers) + : undefined; + const node = ts.factory.createExportDeclaration( undefined, isTypeOnly, - ts.factory.createNamedExports(namedSpecifiers), + exportClause, tsc.stringLiteral({ isSingleQuote: true, text: from }), ); - statements.push(tsNodeToString({ node })); - } - - if (statements.length) { - statements.push(''); + lines.push(tsNodeToString({ node, unescape: true })); } - let exports = statements.join('\n'); - exports = replaceWrappedIds(exports, (symbolId) => - this.replacerFn({ file, headless: false, scope: 'file', symbolId }), - ); - return exports; + return lines; } - 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 getHeaderLines(): Array { + return ['// This file is auto-generated by @hey-api/openapi-ts']; } - private renderHeaders(): string { - return ['// This file is auto-generated by @hey-api/openapi-ts', ''].join( - '\n', - ); - } + private getImportLines( + bindings: Map, + file: File, + project: IProject, + ): Array { + const lines: Array = []; - private renderImports(file: ICodegenFile, meta?: ICodegenMeta): string { - const grouped = this.groupByKey(file, 'imports', meta); - const statements: Array = []; + let lastGroup = -1; + const importSortKey = (binding: Binding): [number, number, string] => { + const path = binding.from; + if (!path.startsWith('.')) { + // Node.js built-in + if (nodeBuiltins.has(path.split('/')[0]!)) { + return [0, 0, path]; + } + // external package + return [1, 0, path]; + } + // sibling relative + if (path.startsWith('./')) { + return [2, 0, path]; + } + // parent relative + const parentCount = path.match(/\.\.\//g)?.length ?? 0; + return [2, parentCount, path]; + }; - for (const [from, group] of grouped.entries()) { + const sortedBindings = Array.from(bindings.values()) + .map((value) => ({ + ...value, + k: importSortKey(value), + })) + .sort( + (a, b) => + a.k[0] - b.k[0] || a.k[1] - b.k[1] || a.k[2].localeCompare(b.k[2]), + ); + + for (const value of sortedBindings) { const specifiers: Array = []; - let defaultImport: ts.Identifier | undefined; - let namespaceImport: string | undefined; + let defaultBinding: ts.Identifier | undefined; + let namespaceBinding: string | undefined; let isTypeOnly = false; - for (const value of group) { - if (value.defaultImport) { - defaultImport = tsc.identifier({ text: value.defaultImport }); - if (value.typeDefaultImport) { - isTypeOnly = true; - } + if (value.defaultBinding) { + defaultBinding = tsc.identifier({ text: value.defaultBinding }); + if (value.typeDefaultBinding) { + isTypeOnly = true; } - - if (typeof value.namespaceImport === 'string') { - namespaceImport = replaceWrappedIds( - value.namespaceImport, - (symbolId) => this.replacerFn({ file, symbolId }), - ); - if (value.typeNamespaceImport) { - isTypeOnly = true; - } + } else if (typeof value.namespaceBinding === 'string') { + namespaceBinding = renderIds(value.namespaceBinding, (symbolId) => { + const symbol = project.symbols.get(symbolId); + return this.replacerFn({ file, project, symbol }); + }); + if (value.typeNamespaceBinding) { + isTypeOnly = true; + } + } else if (value.names && value.names.length > 0) { + if ( + !isTypeOnly && + value.names.every((name) => value.typeNames?.includes(name)) + ) { + isTypeOnly = true; } - if (value.names && value.names.length > 0) { - if ( - !isTypeOnly && - value.names.every((name) => value.typeNames?.includes(name)) - ) { - isTypeOnly = true; + 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; } - - 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; - } + finalName = renderIds(finalName, (symbolId) => { + const symbol = project.symbols.get(symbolId); + const name = this.replacerFn({ file, project, symbol }); + const [symbolFile] = project.symbolIdToFiles(symbolId); + const sourceName = symbolFile + ? symbolFile.resolvedNames.get(symbolId) + : undefined; + if (sourceName && sourceName !== name) { + // handle only simple imports for now + if (!finalAlias) { + finalAlias = sourceName; } - return name; + } + return name; + }); + if (finalAlias) { + finalAlias = renderIds(finalAlias, (symbolId) => { + const symbol = project.symbols.get(symbolId); + return this.replacerFn({ file, project, symbol }); }); - if (finalAlias) { - finalAlias = replaceWrappedIds(finalAlias, (symbolId) => - this.replacerFn({ file, symbolId }), - ); - // remove redundant alias - if (finalAlias === finalName) { - finalAlias = undefined; - } + // 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 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 + defaultBinding, + namespaceBinding ? ts.factory.createNamespaceImport( - tsc.identifier({ text: namespaceImport }), + tsc.identifier({ text: namespaceBinding }), ) : specifiers.length ? ts.factory.createNamedImports(specifiers) @@ -256,51 +358,108 @@ export class TypeScriptRenderer implements ICodegenRenderer { const node = ts.factory.createImportDeclaration( undefined, importClause, - tsc.stringLiteral({ isSingleQuote: true, text: from }), + tsc.stringLiteral({ isSingleQuote: true, text: value.from }), ); - statements.push(tsNodeToString({ node })); + + if (lastGroup !== -1 && value.k[0] !== lastGroup) { + lines.push(''); // add empty line between groups + } + + lines.push(tsNodeToString({ node, unescape: true })); + lastGroup = value.k[0]; } - if (statements.length) { - statements.push(''); + return lines; + } + + private getUniqueName(base: string, names: BiMap): string { + let index = 2; + let name = base; + while (names.hasValue(name)) { + name = `${base}${index}`; + index += 1; } + return name; + } - return statements.join('\n'); + renderFile( + symbolsAndExports: string, + file: File, + project: IProject, + meta?: ProjectRenderMeta, + ): string { + const imports: Map = new Map(); + symbolsAndExports = renderIds(symbolsAndExports, (symbolId) => { + const symbol = project.symbols.get(symbolId); + const replaced = this.replacerFn({ file, project, symbol }); + if (symbol) { + this.addBinding({ bindings: imports, file, meta, project, symbol }); + } + return replaced; + }); + if (!symbolsAndExports.length) return ''; + let output = ''; + const headerLines = this.getHeaderLines(); + output += `${headerLines.join('\n')}${headerLines.length ? '\n\n' : ''}`; + const importLines = this.getImportLines(imports, file, project); + output += `${importLines.join('\n')}${importLines.length ? '\n\n' : ''}`; + return `${output}${symbolsAndExports}`; } - renderSymbols(file: ICodegenFile, meta?: ICodegenMeta): string { - if (!file.hasContent()) { - return ''; + renderSymbols( + file: File, + project: IProject, + meta?: ProjectRenderMeta, + ): string { + const exports: Map = new Map(); + let output = ''; + const bodyLines = this.getBodyLines(file, project); + output += `${bodyLines.join('\n\n')}${bodyLines.length ? '\n' : ''}`; + output = renderIds(output, (symbolId) => { + if (!file.symbols.body.includes(symbolId)) return; + const symbol = project.symbols.get(symbolId); + return this.replacerFn({ file, project, symbol }); + }); + for (const symbolId of file.symbols.exports) { + const symbol = project.symbols.get(symbolId); + if (symbol) { + this.addBinding({ bindings: exports, file, meta, project, symbol }); + } + } + // cast everything into namespace exports for now + for (const binding of exports.values()) { + binding.namespaceBinding = true; + binding.typeNamespaceBinding = + binding.names && + binding.typeNames && + binding.names.length === binding.typeNames.length && + binding.names.every((name) => (binding.typeNames ?? []).includes(name)); } - const result = [this.renderBody(file), this.renderExports(file, meta)] - .filter(Boolean) - .join('\n'); - return result.endsWith('\n') ? result : `${result}\n`; + const exportLines = this.getExportLines(exports, file, project); + output += `${exportLines.join('\n')}${exportLines.length ? '\n' : ''}`; + return output; } - replacerFn({ + private replacerFn({ file, - headless = true, - scope = 'project', - symbolId, + project, + symbol, }: { - file: ICodegenFile; - headless?: boolean; - scope?: 'file' | 'project'; - symbolId: number; + file: File; + project: IProject; + symbol: Symbol | undefined; }): string | undefined { - const cached = file.resolvedNames.get(symbolId); + if (!symbol) return; + const cached = file.resolvedNames.get(symbol.id); 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 (!symbol.name) return; + const [symbolFile] = project.symbolIdToFiles(symbol.id); + const symbolFileResolvedName = symbolFile?.resolvedNames.get(symbol.id); + let name = ensureValidIdentifier(symbolFileResolvedName ?? symbol.name); if (file.resolvedNames.hasValue(name)) { name = this.getUniqueName(name, file.resolvedNames); } - file.resolvedNames.set(symbolId, name); + file.resolvedNames.set(symbol.id, name); return name; } } diff --git a/packages/openapi-ts/src/getSpec.ts b/packages/openapi-ts/src/getSpec.ts index aac442a6f..def64e47c 100644 --- a/packages/openapi-ts/src/getSpec.ts +++ b/packages/openapi-ts/src/getSpec.ts @@ -32,7 +32,7 @@ export const getSpec = async ({ }: { fetchOptions?: RequestInit; inputPath: Config['input']['path']; - timeout: number; + timeout: number | undefined; watch: WatchValues; }): Promise => { const refParser = new $RefParser(); diff --git a/packages/openapi-ts/src/index.ts b/packages/openapi-ts/src/index.ts index face419d9..8e3a33617 100644 --- a/packages/openapi-ts/src/index.ts +++ b/packages/openapi-ts/src/index.ts @@ -1,3 +1,5 @@ +import './overrides.d.ts'; + import colors from 'ansi-colors'; // @ts-expect-error import colorSupport from 'color-support'; diff --git a/packages/openapi-ts/src/ir/context.ts b/packages/openapi-ts/src/ir/context.ts index c9b1ce7ee..3fb4d8f90 100644 --- a/packages/openapi-ts/src/ir/context.ts +++ b/packages/openapi-ts/src/ir/context.ts @@ -1,16 +1,13 @@ -import path from 'node:path'; - -import { CodegenProject } from '@hey-api/codegen-core'; +import { Project } from '@hey-api/codegen-core'; import type { Package } from '../config/utils/package'; import { packageFactory } from '../config/utils/package'; -import { GeneratedFile } from '../generate/file'; import { TypeScriptRenderer } from '../generate/renderer'; +import { buildName } from '../openApi/shared/utils/name'; import type { PluginConfigMap } from '../plugins/config'; import { PluginInstance } from '../plugins/shared/utils/instance'; import type { PluginNames } from '../plugins/types'; import type { Config } from '../types/config'; -import type { Files } from '../types/utils'; import type { Logger } from '../utils/logger'; import { resolveRef } from '../utils/ref'; import type { IR } from './types'; @@ -20,37 +17,38 @@ export class IRContext = any> { * Configuration for parsing and generating the output. This * is a mix of user-provided and default values. */ - public config: Config; + config: Config; /** - * A map of files that will be generated from `spec`. + * The code generation project instance used to manage files, symbols, */ - public files: Files = {}; - public gen: CodegenProject; + gen: Project; /** * Intermediate representation model obtained from `spec`. */ - public ir: IR.Model = {}; - /** Logger instance */ - public logger: Logger; + ir: IR.Model = {}; + /** + * Logger instance. + */ + logger: Logger; /** * The package metadata and utilities for the current context, constructed * from the provided dependencies. Used for managing package-related * information such as name, version, and dependency resolution during * code generation. */ - public package: Package; + package: Package; /** * A map of registered plugin instances, keyed by plugin name. Plugins are * registered through the `registerPlugin` method and can be accessed by * their configured name from the config. */ - public plugins: Partial< + plugins: Partial< Record> > = {}; /** * Resolved specification from `input`. */ - public spec: Spec; + spec: Spec; constructor({ config, @@ -64,44 +62,36 @@ export class IRContext = any> { spec: Spec; }) { this.config = config; - this.gen = new CodegenProject(); + this.gen = new Project({ + defaultFileName: 'index', + fileName: (base) => { + const name = buildName({ + config: config.output.fileName, + name: base, + }); + const { suffix } = config.output.fileName; + if (!suffix) { + return name; + } + return name === 'index' || name.endsWith(suffix) + ? name + : `${name}${suffix}`; + }, + renderers: { + // TODO: allow overriding via config with custom renderers + '.ts': new TypeScriptRenderer(), + }, + root: config.output.path, + }); this.logger = logger; this.package = packageFactory(dependencies); this.spec = spec; - - if (config.output.indexFile) { - this.gen.createFile('index', { - extension: '.ts', - renderer: new TypeScriptRenderer(), - }); - } - } - - /** - * Create and return a new TypeScript file. Also set the current file context - * to the newly created file. - */ - public createFile(file: IR.ContextFile): GeneratedFile { - // TODO: parser - handle attempt to create duplicate - const outputParts = file.path.split('/'); - const outputDir = path.resolve( - this.config.output.path, - ...outputParts.slice(0, outputParts.length - 1), - ); - const createdFile = new GeneratedFile({ - dir: outputDir, - exportFromIndex: file.exportFromIndex, - id: file.id, - name: `${outputParts[outputParts.length - 1]}.ts`, - }); - this.files[file.id] = createdFile; - return createdFile; } /** * Returns a resolved and dereferenced schema from `spec`. */ - public dereference(schema: { $ref: string }) { + dereference(schema: { $ref: string }) { const resolved = this.resolveRef(schema.$ref); const dereferenced = { ...schema, @@ -112,13 +102,6 @@ export class IRContext = any> { return dereferenced; } - /** - * Returns a specific file by ID from `files`. - */ - public file({ id }: Pick): GeneratedFile | undefined { - return this.files[id]; - } - /** * Registers a new plugin to the global context. * @@ -137,7 +120,7 @@ export class IRContext = any> { gen: this.gen, handler: plugin.handler, name: plugin.name, - output: plugin.output!, + output: plugin.output as string, }); this.plugins[instance.name] = instance; return instance; @@ -150,7 +133,7 @@ export class IRContext = any> { * * @returns {ReadonlyArray} An array of registered plugin instances in order. */ - public registerPlugins(): ReadonlyArray { + registerPlugins(): ReadonlyArray { return this.config.pluginOrder.map((name) => this.registerPlugin(name)); } @@ -158,7 +141,7 @@ export class IRContext = any> { // for now, they map 1:1, but if they diverge (like with OpenAPI 2.0), // we will want to rewrite $refs at parse time, so they continue pointing // to the correct IR location - public resolveIrRef($ref: string) { + resolveIrRef($ref: string) { return resolveRef({ $ref, spec: this.ir, @@ -168,7 +151,7 @@ export class IRContext = any> { /** * Returns a resolved reference from `spec`. */ - public resolveRef($ref: string) { + resolveRef($ref: string) { return resolveRef({ $ref, spec: this.spec, diff --git a/packages/openapi-ts/src/ir/types.d.ts b/packages/openapi-ts/src/ir/types.d.ts index 435e04ba1..309053d34 100644 --- a/packages/openapi-ts/src/ir/types.d.ts +++ b/packages/openapi-ts/src/ir/types.d.ts @@ -1,3 +1,5 @@ +import type { Symbol } from '@hey-api/codegen-core'; + import type { JsonSchemaDraft2020_12 } from '../openApi/3.1.x/types/json-schema-draft-2020-12'; import type { SecuritySchemeObject, @@ -24,24 +26,6 @@ interface IRComponentsObject { schemas?: Record; } -interface IRContextFile { - /** - * Should the exports from this file be re-exported in the index barrel file? - */ - exportFromIndex?: boolean; - /** - * Unique file identifier. - */ - id: string; - /** - * Relative file path to the output path. - * - * @example - * 'bar/foo.ts' - */ - path: string; -} - interface IRHooks { /** * Hooks specifically for overriding operations behavior. @@ -64,11 +48,18 @@ interface IRHooks { * 2. If `isQuery` or `isMutation` returns `undefined`, the result of `getKind` is used. * * @param operation - The operation object to classify. - * @returns An array containing one or more of 'query' or 'mutation'. + * @returns An array containing one or more of 'query' or 'mutation', or undefined to fallback to default behavior. + * @example + * getKind: (operation) => { + * if (operation.method === 'get' && operation.path === '/search') { + * return ['query', 'mutation']; + * } + * return; // fallback to default behavior + * } */ getKind?: ( operation: IROperationObject, - ) => ReadonlyArray<'mutation' | 'query'>; + ) => ReadonlyArray<'mutation' | 'query'> | undefined; /** * Check if the given operation should be treated as a mutation. * @@ -81,6 +72,13 @@ interface IRHooks { * * @param operation - The operation object to check. * @returns true if the operation is a mutation, false otherwise, or undefined to fallback to `getKind`. + * @example + * isMutation: (operation) => { + * if (operation.method === 'post' && operation.path === '/search') { + * return true; + * } + * return; // fallback to default behavior + } */ isMutation?: (operation: IROperationObject) => boolean | undefined; /** @@ -95,9 +93,31 @@ interface IRHooks { * * @param operation - The operation object to check. * @returns true if the operation is a query, false otherwise, or undefined to fallback to `getKind`. + * @example + * isQuery: (operation) => { + * if (operation.method === 'post' && operation.path === '/search') { + * return true; + * } + * return; // fallback to default behavior + } */ isQuery?: (operation: IROperationObject) => boolean | undefined; }; + /** + * Hooks specifically for overriding symbols behavior. + * + * Use these to customize file placement. + */ + symbols?: { + /** + * Optional output strategy to override default plugin behavior. + * + * Use this to route generated symbols to specific files. + * + * @returns The file path to output the symbol to, or undefined to fallback to default behavior. + */ + getFilePath?: (symbol: Symbol) => string | undefined; + }; } interface IROperationObject { @@ -223,18 +243,19 @@ interface IRSchemaObject * receives the "readonly" TypeScript keyword. */ accessScope?: 'read' | 'write'; - /** - * Similar to `accessScope`, but tells us whether the schema as a whole - * contains any read-only or write-only fields. This value controls whether - * we split the schema into individual schemas for payloads and responses. - */ - accessScopes?: ReadonlyArray<'both' | 'read' | 'write'>; /** * If type is `object`, `additionalProperties` can be used to either define * a schema for properties not included in `properties` or disallow such * properties altogether. */ additionalProperties?: IRSchemaObject | false; + /** + * If this schema is a $ref and is circular (points to itself or is in the current resolution stack), + * this flag is set to true. + * + * @default undefined + */ + circular?: boolean; /** * Any string value is accepted as `format`. */ @@ -247,6 +268,7 @@ interface IRSchemaObject /** * When resolving a list of items, we need to know the relationship between * them. `logicalOperator` specifies this logical relationship. + * * @default 'or' */ logicalOperator?: 'and' | 'or'; @@ -303,7 +325,6 @@ export namespace IR { export type BodyObject = IRBodyObject; export type ComponentsObject = IRComponentsObject; export type Context = any> = IRContext; - export type ContextFile = IRContextFile; export type Hooks = IRHooks; export type Model = IRModel; export type OperationObject = IROperationObject; diff --git a/packages/openapi-ts/src/ir/utils.ts b/packages/openapi-ts/src/ir/utils.ts index 27fb9fc92..6307b5e8c 100644 --- a/packages/openapi-ts/src/ir/utils.ts +++ b/packages/openapi-ts/src/ir/utils.ts @@ -1,22 +1,5 @@ -import { mergeSchemaAccessScopes } from '../openApi/shared/utils/schema'; import type { IR } from './types'; -const assignItems = ({ - items, - schema, -}: { - items: Array; - schema: IR.SchemaObject; -}) => { - for (const item of items) { - schema.accessScopes = mergeSchemaAccessScopes( - schema.accessScopes, - item.accessScopes, - ); - } - schema.items = items; -}; - /** * Simply adds `items` to the schema. Also handles setting the logical operator * and avoids setting it for a single item or tuples. @@ -37,12 +20,12 @@ export const addItemsToSchema = ({ } if (schema.type === 'tuple') { - assignItems({ items, schema }); + schema.items = items; return schema; } if (items.length !== 1) { - assignItems({ items, schema }); + schema.items = items; schema.logicalOperator = logicalOperator; return schema; } @@ -56,6 +39,6 @@ export const addItemsToSchema = ({ return schema; } - assignItems({ items, schema }); + schema.items = items; return schema; }; diff --git a/packages/openapi-ts/src/openApi/2.0.x/parser/parameter.ts b/packages/openapi-ts/src/openApi/2.0.x/parser/parameter.ts index 981aa6968..cc1117d46 100644 --- a/packages/openapi-ts/src/openApi/2.0.x/parser/parameter.ts +++ b/packages/openapi-ts/src/openApi/2.0.x/parser/parameter.ts @@ -85,6 +85,7 @@ export const parametersArrayToObject = ({ // lowercase keys for case insensitive access parametersObject[parameter.in]![parameter.name.toLocaleLowerCase()] = parameterToIrParameter({ + $ref: `#/todo/real/path/to/parameter/${parameter.name}`, context, parameter, }); @@ -94,9 +95,11 @@ export const parametersArrayToObject = ({ }; const parameterToIrParameter = ({ + $ref, context, parameter, }: { + $ref: string; context: IR.Context; parameter: Parameter; }): IR.ParameterObject => { @@ -140,7 +143,11 @@ const parameterToIrParameter = ({ schema: schemaToIrSchema({ context, schema: finalSchema, - state: undefined, + state: { + $ref, + circularReferenceTracker: new Set(), + refStack: [$ref], + }, }), style, }; diff --git a/packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts b/packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts index 82557cd73..b2357d7cc 100644 --- a/packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts @@ -7,7 +7,6 @@ import type { SchemaWithRequired, } from '../../shared/types/schema'; import { discriminatorValues } from '../../shared/utils/discriminator'; -import { mergeSchemaAccessScopes } from '../../shared/utils/schema'; import type { SchemaObject } from '../types/spec'; export const getSchemaType = ({ @@ -50,11 +49,9 @@ const parseSchemaJsDoc = ({ const parseSchemaMeta = ({ irSchema, schema, - state, }: { irSchema: IR.SchemaObject; schema: SchemaObject; - state: SchemaState; }) => { if (schema.default !== undefined) { irSchema.default = schema.default; @@ -102,13 +99,6 @@ const parseSchemaMeta = ({ if (schema.readOnly) { irSchema.accessScope = 'read'; - irSchema.accessScopes = mergeSchemaAccessScopes(irSchema.accessScopes, [ - 'read', - ]); - } else if (state.isProperty) { - irSchema.accessScopes = mergeSchemaAccessScopes(irSchema.accessScopes, [ - 'both', - ]); } }; @@ -138,11 +128,6 @@ const parseArray = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irItemsSchema.accessScopes, - ); - if ( !schemaItems.length && schema.maxItems && @@ -225,15 +210,8 @@ const parseObject = ({ const irPropertySchema = schemaToIrSchema({ context, schema: property, - state: { - ...state, - isProperty: true, - }, + state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irPropertySchema.accessScopes, - ); schemaProperties[name] = irPropertySchema; } } @@ -322,25 +300,20 @@ const parseAllOf = ({ const compositionSchemas = schema.allOf; for (const compositionSchema of compositionSchemas) { + const originalInAllOf = state.inAllOf; // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components - const isRef = '$ref' in compositionSchema; - const schemaState = isRef - ? state - : { - ...state, - inAllOf: true, - }; - + if (!('$ref' in compositionSchema)) { + state.inAllOf = true; + } const irCompositionSchema = schemaToIrSchema({ context, schema: compositionSchema, - state: schemaState, + state, }); - - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irCompositionSchema.accessScopes, - ); + state.inAllOf = originalInAllOf; + if (state.inAllOf === undefined) { + delete state.inAllOf; + } if (schema.required) { if (irCompositionSchema.required) { @@ -383,21 +356,6 @@ const parseAllOf = ({ } schemaItems.push(irDiscriminatorSchema); } - - if (!state.circularReferenceTracker.has(compositionSchema.$ref)) { - const irRefSchema = schemaToIrSchema({ - context, - schema: ref, - state: { - ...state, - $ref: compositionSchema.$ref, - }, - }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irRefSchema.accessScopes, - ); - } } } @@ -411,11 +369,6 @@ const parseAllOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irObjectSchema.accessScopes, - ); - if (irObjectSchema.properties) { for (const requiredProperty of irObjectSchema.required ?? []) { if (!irObjectSchema.properties[requiredProperty]) { @@ -437,11 +390,6 @@ const parseAllOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irCompositionSchema.accessScopes, - ); - if (irCompositionSchema.properties?.[requiredProperty]) { irObjectSchema.properties[requiredProperty] = irCompositionSchema.properties[requiredProperty]; @@ -562,11 +510,6 @@ const parseEnum = ({ irTypeSchema.type = 'tuple'; } - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irTypeSchema.accessScopes, - ); - schemaItems.push(irTypeSchema); } @@ -592,16 +535,18 @@ const parseRef = ({ const isComponentsRef = schema.$ref.startsWith('#/definitions/'); if (!isComponentsRef) { if (!state.circularReferenceTracker.has(schema.$ref)) { + state.refStack.push(schema.$ref); const refSchema = context.resolveRef(schema.$ref); - return schemaToIrSchema({ + const originalRef = state.$ref; + state.$ref = schema.$ref; + const irSchema = schemaToIrSchema({ context, schema: refSchema, - state: { - ...state, - $ref: schema.$ref, - isProperty: false, - }, + state, }); + state.$ref = originalRef; + state.refStack.pop(); + return irSchema; } // Fallback to preserving the ref if circular } @@ -617,21 +562,28 @@ const parseRef = ({ '#/components/schemas/$1', ); + if (state.refStack.includes(schema.$ref)) { + if (state.refStack[0] === schema.$ref) { + state.circularRef = schema.$ref; + } + irSchema.circular = true; + } + if (!state.circularReferenceTracker.has(schema.$ref)) { + state.refStack.push(schema.$ref); const refSchema = context.resolveRef(schema.$ref); - const irRefSchema = schemaToIrSchema({ + const originalRef = state.$ref; + state.$ref = schema.$ref; + schemaToIrSchema({ context, schema: refSchema, - state: { - ...state, - $ref: schema.$ref, - isProperty: false, - }, + state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irRefSchema.accessScopes, - ); + if (state.circularRef && state.refStack[0] === state.circularRef) { + irSchema.circular = true; + } + state.$ref = originalRef; + state.refStack.pop(); } return irSchema; @@ -654,11 +606,7 @@ const parseNullableType = ({ const typeIrSchema: IR.SchemaObject = {}; - parseSchemaMeta({ - irSchema: typeIrSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema: typeIrSchema, schema }); if (typeIrSchema.default === null) { // clear to avoid duplicate default inside the non-null schema. @@ -697,11 +645,7 @@ const parseType = ({ }): IR.SchemaObject => { const irSchema = initIrSchema({ schema }); - parseSchemaMeta({ - irSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema, schema }); const type = getSchemaType({ schema }); @@ -746,11 +690,7 @@ const parseOneType = ({ if (!irSchema) { irSchema = initIrSchema({ schema }); - parseSchemaMeta({ - irSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema, schema }); } switch (schema.type) { @@ -796,7 +736,6 @@ const parseOneType = ({ context, irSchema, schema, - state, }); } }; @@ -804,12 +743,10 @@ const parseOneType = ({ const parseUnknown = ({ irSchema, schema, - state, }: { context: IR.Context; irSchema?: IR.SchemaObject; schema: SchemaObject; - state: SchemaState; }): IR.SchemaObject => { if (!irSchema) { irSchema = initIrSchema({ schema }); @@ -817,11 +754,7 @@ const parseUnknown = ({ irSchema.type = 'unknown'; - parseSchemaMeta({ - irSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema, schema }); return irSchema; }; @@ -838,6 +771,7 @@ export const schemaToIrSchema = ({ if (!state) { state = { circularReferenceTracker: new Set(), + refStack: [], }; } @@ -878,11 +812,7 @@ export const schemaToIrSchema = ({ }); } - return parseUnknown({ - context, - schema, - state, - }); + return parseUnknown({ context, schema }); }; export const parseSchema = ({ @@ -908,6 +838,7 @@ export const parseSchema = ({ state: { $ref, circularReferenceTracker: new Set(), + refStack: [$ref], }, }); }; diff --git a/packages/openapi-ts/src/openApi/3.0.x/parser/parameter.ts b/packages/openapi-ts/src/openApi/3.0.x/parser/parameter.ts index b1c4ccf83..75f1a5fa6 100644 --- a/packages/openapi-ts/src/openApi/3.0.x/parser/parameter.ts +++ b/packages/openapi-ts/src/openApi/3.0.x/parser/parameter.ts @@ -81,6 +81,7 @@ export const parametersArrayToObject = ({ // lowercase keys for case insensitive access parametersObject[parameter.in]![parameter.name.toLocaleLowerCase()] = parameterToIrParameter({ + $ref: `#/todo/real/path/to/parameter/${parameter.name}`, context, parameter, }); @@ -90,9 +91,11 @@ export const parametersArrayToObject = ({ }; const parameterToIrParameter = ({ + $ref, context, parameter, }: { + $ref: string; context: IR.Context; parameter: ParameterObject; }): IR.ParameterObject => { @@ -144,7 +147,11 @@ const parameterToIrParameter = ({ schema: schemaToIrSchema({ context, schema: finalSchema, - state: undefined, + state: { + $ref, + circularReferenceTracker: new Set(), + refStack: [$ref], + }, }), style, }; @@ -186,6 +193,7 @@ export const parseParameter = ({ } context.ir.components.parameters[refToName($ref)] = parameterToIrParameter({ + $ref, context, parameter, }); diff --git a/packages/openapi-ts/src/openApi/3.0.x/parser/requestBody.ts b/packages/openapi-ts/src/openApi/3.0.x/parser/requestBody.ts index 2198ed38f..2aa311f4d 100644 --- a/packages/openapi-ts/src/openApi/3.0.x/parser/requestBody.ts +++ b/packages/openapi-ts/src/openApi/3.0.x/parser/requestBody.ts @@ -5,9 +5,11 @@ import { mediaTypeObjects } from './mediaType'; import { schemaToIrSchema } from './schema'; const requestBodyToIrRequestBody = ({ + $ref, context, requestBody, }: { + $ref: string; context: IR.Context; requestBody: RequestBodyObject; }): IR.RequestBodyObject => { @@ -27,7 +29,11 @@ const requestBodyToIrRequestBody = ({ schema: schemaToIrSchema({ context, schema: finalSchema, - state: undefined, + state: { + $ref, + circularReferenceTracker: new Set(), + refStack: [$ref], + }, }), }; @@ -61,6 +67,7 @@ export const parseRequestBody = ({ context.ir.components.requestBodies[refToName($ref)] = requestBodyToIrRequestBody({ + $ref, context, requestBody, }); diff --git a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts index 60af07a36..1cd74e69c 100644 --- a/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts @@ -7,7 +7,6 @@ import type { SchemaWithRequired, } from '../../shared/types/schema'; import { discriminatorValues } from '../../shared/utils/discriminator'; -import { mergeSchemaAccessScopes } from '../../shared/utils/schema'; import type { ReferenceObject, SchemaObject } from '../types/spec'; export const getSchemaType = ({ @@ -54,11 +53,9 @@ const parseSchemaJsDoc = ({ const parseSchemaMeta = ({ irSchema, schema, - state, }: { irSchema: IR.SchemaObject; schema: SchemaObject; - state: SchemaState; }) => { if (schema.default !== undefined) { irSchema.default = schema.default; @@ -106,18 +103,8 @@ const parseSchemaMeta = ({ if (schema.readOnly) { irSchema.accessScope = 'read'; - irSchema.accessScopes = mergeSchemaAccessScopes(irSchema.accessScopes, [ - 'read', - ]); } else if (schema.writeOnly) { irSchema.accessScope = 'write'; - irSchema.accessScopes = mergeSchemaAccessScopes(irSchema.accessScopes, [ - 'write', - ]); - } else if (state.isProperty) { - irSchema.accessScopes = mergeSchemaAccessScopes(irSchema.accessScopes, [ - 'both', - ]); } }; @@ -147,11 +134,6 @@ const parseArray = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irItemsSchema.accessScopes, - ); - if ( !schemaItems.length && schema.maxItems && @@ -232,19 +214,11 @@ const parseObject = ({ if (typeof property === 'boolean') { // TODO: parser - handle boolean properties } else { - const irPropertySchema = schemaToIrSchema({ + schemaProperties[name] = schemaToIrSchema({ context, schema: property, - state: { - ...state, - isProperty: true, - }, + state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irPropertySchema.accessScopes, - ); - schemaProperties[name] = irPropertySchema; } } @@ -332,25 +306,20 @@ const parseAllOf = ({ const compositionSchemas = schema.allOf; for (const compositionSchema of compositionSchemas) { + const originalInAllOf = state.inAllOf; // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components - const isRef = '$ref' in compositionSchema; - const schemaState = isRef - ? state - : { - ...state, - inAllOf: true, - }; - + if (!('$ref' in compositionSchema)) { + state.inAllOf = true; + } const irCompositionSchema = schemaToIrSchema({ context, schema: compositionSchema, - state: schemaState, + state, }); - - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irCompositionSchema.accessScopes, - ); + state.inAllOf = originalInAllOf; + if (state.inAllOf === undefined) { + delete state.inAllOf; + } if (schema.required) { if (irCompositionSchema.required) { @@ -405,21 +374,6 @@ const parseAllOf = ({ schemaItems.push(irDiscriminatorSchema); } } - - if (!state.circularReferenceTracker.has(compositionSchema.$ref)) { - const irRefSchema = schemaToIrSchema({ - context, - schema: ref, - state: { - ...state, - $ref: compositionSchema.$ref, - }, - }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irRefSchema.accessScopes, - ); - } } } @@ -433,11 +387,6 @@ const parseAllOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irObjectSchema.accessScopes, - ); - if (irObjectSchema.properties) { for (const requiredProperty of irObjectSchema.required ?? []) { if (!irObjectSchema.properties[requiredProperty]) { @@ -460,11 +409,6 @@ const parseAllOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irCompositionSchema.accessScopes, - ); - if (irCompositionSchema.properties?.[requiredProperty]) { irObjectSchema.properties[requiredProperty] = irCompositionSchema.properties[requiredProperty]; @@ -541,11 +485,6 @@ const parseAnyOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irCompositionSchema.accessScopes, - ); - // `$ref` should be defined with discriminators if (schema.discriminator && irCompositionSchema.$ref != null) { const values = discriminatorValues( @@ -600,11 +539,6 @@ const parseAnyOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irObjectSchema.accessScopes, - ); - if (irObjectSchema.properties) { irSchema = { items: [irSchema, irObjectSchema], @@ -683,11 +617,6 @@ const parseEnum = ({ irTypeSchema.type = 'tuple'; } - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irTypeSchema.accessScopes, - ); - schemaItems.push(irTypeSchema); } @@ -722,11 +651,6 @@ const parseOneOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irCompositionSchema.accessScopes, - ); - // `$ref` should be defined with discriminators if (schema.discriminator && irCompositionSchema.$ref != null) { const values = discriminatorValues( @@ -793,11 +717,6 @@ const parseOneOf = ({ state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irObjectSchema.accessScopes, - ); - if (irObjectSchema.properties) { irSchema = { items: [irSchema, irObjectSchema], @@ -822,16 +741,18 @@ const parseRef = ({ const isComponentsRef = schema.$ref.startsWith('#/components/'); if (!isComponentsRef) { if (!state.circularReferenceTracker.has(schema.$ref)) { + state.refStack.push(schema.$ref); const refSchema = context.resolveRef(schema.$ref); - return schemaToIrSchema({ + const originalRef = state.$ref; + state.$ref = schema.$ref; + const irSchema = schemaToIrSchema({ context, schema: refSchema, - state: { - ...state, - $ref: schema.$ref, - isProperty: false, - }, + state, }); + state.$ref = originalRef; + state.refStack.pop(); + return irSchema; } // Fallback to preserving the ref if circular } @@ -842,21 +763,28 @@ const parseRef = ({ // but the suspicion is this comes from `@hey-api/json-schema-ref-parser` irSchema.$ref = decodeURI(schema.$ref); + if (state.refStack.includes(schema.$ref)) { + if (state.refStack[0] === schema.$ref) { + state.circularRef = schema.$ref; + } + irSchema.circular = true; + } + if (!state.circularReferenceTracker.has(schema.$ref)) { + state.refStack.push(schema.$ref); const refSchema = context.resolveRef(schema.$ref); - const irRefSchema = schemaToIrSchema({ + const originalRef = state.$ref; + state.$ref = schema.$ref; + schemaToIrSchema({ context, schema: refSchema, - state: { - ...state, - $ref: schema.$ref, - isProperty: false, - }, + state, }); - irSchema.accessScopes = mergeSchemaAccessScopes( - irSchema.accessScopes, - irRefSchema.accessScopes, - ); + if (state.circularRef && state.refStack[0] === state.circularRef) { + irSchema.circular = true; + } + state.$ref = originalRef; + state.refStack.pop(); } return irSchema; @@ -879,11 +807,7 @@ const parseNullableType = ({ const typeIrSchema: IR.SchemaObject = {}; - parseSchemaMeta({ - irSchema: typeIrSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema: typeIrSchema, schema }); if (typeIrSchema.default === null) { // clear to avoid duplicate default inside the non-null schema. @@ -922,11 +846,7 @@ const parseType = ({ }): IR.SchemaObject => { const irSchema = initIrSchema({ schema }); - parseSchemaMeta({ - irSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema, schema }); const type = getSchemaType({ schema }); @@ -971,11 +891,7 @@ const parseOneType = ({ if (!irSchema) { irSchema = initIrSchema({ schema }); - parseSchemaMeta({ - irSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema, schema }); } switch (schema.type) { @@ -1021,7 +937,6 @@ const parseOneType = ({ context, irSchema, schema, - state, }); } }; @@ -1029,12 +944,10 @@ const parseOneType = ({ const parseUnknown = ({ irSchema, schema, - state, }: { context: IR.Context; irSchema?: IR.SchemaObject; schema: SchemaObject; - state: SchemaState; }): IR.SchemaObject => { if (!irSchema) { irSchema = initIrSchema({ schema }); @@ -1042,11 +955,7 @@ const parseUnknown = ({ irSchema.type = 'unknown'; - parseSchemaMeta({ - irSchema, - schema, - state, - }); + parseSchemaMeta({ irSchema, schema }); return irSchema; }; @@ -1063,6 +972,7 @@ export const schemaToIrSchema = ({ if (!state) { state = { circularReferenceTracker: new Set(), + refStack: [], }; } @@ -1119,11 +1029,7 @@ export const schemaToIrSchema = ({ }); } - return parseUnknown({ - context, - schema, - state, - }); + return parseUnknown({ context, schema }); }; export const parseSchema = ({ @@ -1149,6 +1055,7 @@ export const parseSchema = ({ state: { $ref, circularReferenceTracker: new Set(), + refStack: [$ref], }, }); }; diff --git a/packages/openapi-ts/src/openApi/3.1.x/parser/parameter.ts b/packages/openapi-ts/src/openApi/3.1.x/parser/parameter.ts index 14980bf28..13748445d 100644 --- a/packages/openapi-ts/src/openApi/3.1.x/parser/parameter.ts +++ b/packages/openapi-ts/src/openApi/3.1.x/parser/parameter.ts @@ -81,6 +81,7 @@ export const parametersArrayToObject = ({ // lowercase keys for case insensitive access parametersObject[parameter.in]![parameter.name.toLocaleLowerCase()] = parameterToIrParameter({ + $ref: `#/todo/real/path/to/parameter/${parameter.name}`, context, parameter, }); @@ -90,9 +91,11 @@ export const parametersArrayToObject = ({ }; const parameterToIrParameter = ({ + $ref, context, parameter, }: { + $ref: string; context: IR.Context; parameter: ParameterObject; }): IR.ParameterObject => { @@ -137,7 +140,11 @@ const parameterToIrParameter = ({ schema: schemaToIrSchema({ context, schema: finalSchema, - state: undefined, + state: { + $ref, + circularReferenceTracker: new Set(), + refStack: [$ref], + }, }), style, }; @@ -179,6 +186,7 @@ export const parseParameter = ({ } context.ir.components.parameters[refToName($ref)] = parameterToIrParameter({ + $ref, context, parameter, }); diff --git a/packages/openapi-ts/src/openApi/3.1.x/parser/requestBody.ts b/packages/openapi-ts/src/openApi/3.1.x/parser/requestBody.ts index 2198ed38f..2aa311f4d 100644 --- a/packages/openapi-ts/src/openApi/3.1.x/parser/requestBody.ts +++ b/packages/openapi-ts/src/openApi/3.1.x/parser/requestBody.ts @@ -5,9 +5,11 @@ import { mediaTypeObjects } from './mediaType'; import { schemaToIrSchema } from './schema'; const requestBodyToIrRequestBody = ({ + $ref, context, requestBody, }: { + $ref: string; context: IR.Context; requestBody: RequestBodyObject; }): IR.RequestBodyObject => { @@ -27,7 +29,11 @@ const requestBodyToIrRequestBody = ({ schema: schemaToIrSchema({ context, schema: finalSchema, - state: undefined, + state: { + $ref, + circularReferenceTracker: new Set(), + refStack: [$ref], + }, }), }; @@ -61,6 +67,7 @@ export const parseRequestBody = ({ context.ir.components.requestBodies[refToName($ref)] = requestBodyToIrRequestBody({ + $ref, context, requestBody, }); diff --git a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts index 6ff5e7d2d..970fbe622 100644 --- a/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts +++ b/packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts @@ -270,10 +270,7 @@ const parseObject = ({ const irPropertySchema = schemaToIrSchema({ context, schema: property, - state: { - ...state, - isProperty: true, - }, + state, }); schemaProperties[name] = irPropertySchema; } @@ -390,20 +387,20 @@ const parseAllOf = ({ const compositionSchemas = schema.allOf; for (const compositionSchema of compositionSchemas) { + const originalInAllOf = state.inAllOf; // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components - const isRef = '$ref' in compositionSchema; - const schemaState = isRef - ? state - : { - ...state, - inAllOf: true, - }; - + if (!('$ref' in compositionSchema)) { + state.inAllOf = true; + } const irCompositionSchema = schemaToIrSchema({ context, schema: compositionSchema, - state: schemaState, + state, }); + state.inAllOf = originalInAllOf; + if (state.inAllOf === undefined) { + delete state.inAllOf; + } if (schema.required) { if (irCompositionSchema.required) { @@ -457,17 +454,6 @@ const parseAllOf = ({ schemaItems.push(irDiscriminatorSchema); } } - - if (!state.circularReferenceTracker.has(compositionSchema.$ref)) { - schemaToIrSchema({ - context, - schema: ref, - state: { - ...state, - $ref: compositionSchema.$ref, - }, - }); - } } } @@ -814,16 +800,18 @@ const parseRef = ({ const isComponentsRef = schema.$ref.startsWith('#/components/'); if (!isComponentsRef) { if (!state.circularReferenceTracker.has(schema.$ref)) { + state.refStack.push(schema.$ref); const refSchema = context.resolveRef(schema.$ref); - return schemaToIrSchema({ + const originalRef = state.$ref; + state.$ref = schema.$ref; + const irSchema = schemaToIrSchema({ context, schema: refSchema, - state: { - ...state, - $ref: schema.$ref, - isProperty: false, - }, + state, }); + state.$ref = originalRef; + state.refStack.pop(); + return irSchema; } // Fallback to preserving the ref if circular } @@ -836,17 +824,28 @@ const parseRef = ({ // but the suspicion is this comes from `@hey-api/json-schema-ref-parser` irRefSchema.$ref = decodeURI(schema.$ref); + if (state.refStack.includes(schema.$ref)) { + if (state.refStack[0] === schema.$ref) { + state.circularRef = schema.$ref; + } + irSchema.circular = true; + } + if (!state.circularReferenceTracker.has(schema.$ref)) { + state.refStack.push(schema.$ref); const refSchema = context.resolveRef(schema.$ref); + const originalRef = state.$ref; + state.$ref = schema.$ref; schemaToIrSchema({ context, schema: refSchema, - state: { - ...state, - $ref: schema.$ref, - isProperty: false, - }, + state, }); + if (state.circularRef && state.refStack[0] === state.circularRef) { + irSchema.circular = true; + } + state.$ref = originalRef; + state.refStack.pop(); } const schemaItems: Array = []; @@ -1055,6 +1054,7 @@ export const schemaToIrSchema = ({ if (!state) { state = { circularReferenceTracker: new Set(), + refStack: [], }; } @@ -1137,6 +1137,7 @@ export const parseSchema = ({ state: { $ref, circularReferenceTracker: new Set(), + refStack: [$ref], }, }); }; diff --git a/packages/openapi-ts/src/openApi/shared/types/schema.d.ts b/packages/openapi-ts/src/openApi/shared/types/schema.d.ts index f6e3413ae..5b5bb9ecd 100644 --- a/packages/openapi-ts/src/openApi/shared/types/schema.d.ts +++ b/packages/openapi-ts/src/openApi/shared/types/schema.d.ts @@ -4,6 +4,18 @@ export interface SchemaState { * from the OpenAPI specification. */ $ref?: string; + /** + * If a reference is detected as circular, this will hold the $ref string. + * This is used to back-propagate circular reference information to the + * original schema that started the circular reference chain. + */ + circularRef?: string; + /** + * Set of $refs currently being resolved that are circular. This is used to + * avoid infinite loops when resolving schemas with circular references. + * + * @deprecated Use `refStack` instead. + */ circularReferenceTracker: Set; /** * True if current schema is part of an allOf composition. This is used to @@ -13,12 +25,10 @@ export interface SchemaState { */ inAllOf?: boolean; /** - * True if current schema is an object property. This is used to mark schemas - * as "both" access scopes, i.e. they can be used in both payloads and - * responses. Without this field, we'd be overusing the "both" value which - * would effectively render it useless. + * Stack of $refs currently being resolved. This is used to detect circular + * references and avoid infinite loops. */ - isProperty?: boolean; + refStack: Array; } export type SchemaWithRequired< diff --git a/packages/openapi-ts/src/openApi/shared/utils/__tests__/schema.test.ts b/packages/openapi-ts/src/openApi/shared/utils/__tests__/schema.test.ts deleted file mode 100644 index 2ea1bc298..000000000 --- a/packages/openapi-ts/src/openApi/shared/utils/__tests__/schema.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import { mergeSchemaAccessScopes } from '../schema'; - -describe('mergeSchemaAccessScopes', () => { - const scenarios: Array<{ - a: ReadonlyArray<'read' | 'write'> | undefined; - b: ReadonlyArray<'read' | 'write'> | undefined; - result: ReadonlyArray<'read' | 'write'> | undefined; - }> = [ - { - a: undefined, - b: undefined, - result: undefined, - }, - { - a: undefined, - b: ['read'], - result: ['read'], - }, - { - a: ['read'], - b: undefined, - result: ['read'], - }, - { - a: ['read'], - b: ['write'], - result: ['read', 'write'], - }, - { - a: ['read', 'write'], - b: ['read', 'write'], - result: ['read', 'write'], - }, - ]; - - it.each(scenarios)('$a and $b -> $result', ({ a, b, result }) => { - expect(mergeSchemaAccessScopes(a, b)).toEqual(result); - }); -}); diff --git a/packages/openapi-ts/src/openApi/shared/utils/schema.ts b/packages/openapi-ts/src/openApi/shared/utils/schema.ts index c0ef21eb6..497681013 100644 --- a/packages/openapi-ts/src/openApi/shared/utils/schema.ts +++ b/packages/openapi-ts/src/openApi/shared/utils/schema.ts @@ -1,26 +1 @@ export const deepClone = (obj: T): T => JSON.parse(JSON.stringify(obj)); - -/** - * Accepts `accessScopes` from two schemas and returns a merged and - * deduplicated value. - */ -export const mergeSchemaAccessScopes = ( - a: ReadonlyArray<'both' | 'read' | 'write'> | undefined, - b: ReadonlyArray<'both' | 'read' | 'write'> | undefined, -): ReadonlyArray<'both' | 'read' | 'write'> | undefined => { - if (!a?.length) { - return b?.length ? b : undefined; - } - - if (!b?.length) { - return a; - } - - const mergedScopes = new Set(a); - - for (const scope of b) { - mergedScopes.add(scope); - } - - return mergedScopes.size > a.length ? Array.from(mergedScopes) : a; -}; diff --git a/packages/openapi-ts/src/overrides.d.ts b/packages/openapi-ts/src/overrides.d.ts index a4695367a..36b360b8b 100644 --- a/packages/openapi-ts/src/overrides.d.ts +++ b/packages/openapi-ts/src/overrides.d.ts @@ -3,7 +3,14 @@ import '@hey-api/codegen-core'; import type ts from 'typescript'; declare module '@hey-api/codegen-core' { - interface ICodegenMeta { + interface ProjectRenderMeta { moduleResolution?: ts.ModuleResolutionKind; } + + interface SymbolMeta { + /** + * Name of the plugin that registered this symbol. + */ + pluginName?: string; + } } diff --git a/packages/openapi-ts/src/plugins/@angular/common/api.ts b/packages/openapi-ts/src/plugins/@angular/common/api.ts index 78581f485..3cac30850 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/api.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -22,15 +22,13 @@ export type IApi = { * - `Injectable`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@angular/common'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } diff --git a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts index ca4b4b14d..70621302d 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts @@ -1,7 +1,6 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import { TypeScriptRenderer } from '../../../generate/renderer'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; @@ -22,15 +21,11 @@ interface AngularRequestClassEntry { root: boolean; } -const pathSuffix = '/http/requests'; - const generateAngularClassRequests = ({ plugin, }: { plugin: AngularCommonPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); - const requestClasses = new Map(); const generatedClasses = new Set(); @@ -134,16 +129,11 @@ const generateAngularClassRequests = ({ } } - const symbolInjectable = f - .ensureSymbol({ - selector: plugin.api.getSelector('Injectable'), - }) - .update({ name: 'Injectable' }); - f.addImport({ - from: '@angular/core', - names: [symbolInjectable.placeholder], - }); - const symbolClass = f.addSymbol({ + const symbolInjectable = plugin.referenceSymbol( + plugin.api.getSelector('Injectable'), + ); + const symbolClass = plugin.registerSymbol({ + exported: true, name: buildName({ config: { case: 'preserve', @@ -160,11 +150,11 @@ const generateAngularClassRequests = ({ name: symbolInjectable.placeholder, } : undefined, - exportClass: currentClass.root, + exportClass: symbolClass.exported, name: symbolClass.placeholder, nodes: currentClass.nodes, }); - symbolClass.update({ value: node }); + plugin.setSymbolValue(symbolClass, node); generatedClasses.add(currentClass.className); }; @@ -179,15 +169,14 @@ const generateAngularFunctionRequests = ({ }: { 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({ + const symbol = plugin.registerSymbol({ + exported: true, name: plugin.config.httpRequests.methodNameBuilder(operation), selector: plugin.api.getSelector('httpRequest', operation.id), }); @@ -197,7 +186,7 @@ const generateAngularFunctionRequests = ({ plugin, symbol, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, node); }); }; @@ -208,22 +197,14 @@ const generateRequestCallExpression = ({ operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - 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 symbolClient = + client.api && 'getSelector' in client.api + ? plugin.getSymbol( + // @ts-expect-error + client.api.getSelector('client'), + ) + : undefined; const optionsClient = tsc.propertyAccessExpression({ expression: tsc.identifier({ text: 'options' }), @@ -284,38 +265,20 @@ const generateAngularRequestMethod = ({ operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - 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 symbolHttpRequest = plugin.referenceSymbol( + plugin.api.getSelector('HttpRequest'), + ); const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.getSelector('Options'), ); - f.addImport({ - from: symbolOptions.file, - typeNames: [symbolOptions.placeholder], - }); - const symbolDataType = plugin.gen.selectSymbolFirst( + const symbolDataType = plugin.getSymbol( pluginTypeScript.api.getSelector('data', operation.id), ); - if (symbolDataType) { - f.addImport({ - from: symbolDataType.file, - typeNames: [symbolDataType.placeholder], - }); - } const dataType = symbolDataType?.placeholder || 'unknown'; return tsc.methodDeclaration({ @@ -357,45 +320,27 @@ const generateAngularRequestFunction = ({ isRequiredOptions: boolean; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; - symbol: ICodegenSymbolOut; + symbol: Symbol; }) => { - 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 symbolHttpRequest = plugin.referenceSymbol( + plugin.api.getSelector('HttpRequest'), + ); const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.getSelector('Options'), ); - f.addImport({ - from: symbolOptions.file, - typeNames: [symbolOptions.placeholder], - }); - const symbolDataType = plugin.gen.selectSymbolFirst( + const symbolDataType = plugin.getSymbol( 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, + exportConst: symbol.exported, expression: tsc.arrowFunction({ parameters: [ { @@ -428,20 +373,9 @@ const generateAngularRequestFunction = ({ export const createHttpRequests: AngularCommonPlugin['Handler'] = ({ plugin, }) => { - const f = plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - if (plugin.config.httpRequests.asClass) { generateAngularClassRequests({ plugin }); } 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 1712a8fa8..5d1b7f235 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts @@ -1,7 +1,6 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import { TypeScriptRenderer } from '../../../generate/renderer'; import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; @@ -21,15 +20,11 @@ interface AngularServiceClassEntry { root: boolean; } -const pathSuffix = '/http/resources'; - const generateAngularClassServices = ({ plugin, }: { plugin: AngularCommonPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); - const serviceClasses = new Map(); const generatedClasses = new Set(); @@ -133,16 +128,11 @@ const generateAngularClassServices = ({ } } - const symbolInjectable = f - .ensureSymbol({ - selector: plugin.api.getSelector('Injectable'), - }) - .update({ name: 'Injectable' }); - f.addImport({ - from: '@angular/core', - names: [symbolInjectable.placeholder], - }); - const symbolClass = f.addSymbol({ + const symbolInjectable = plugin.referenceSymbol( + plugin.api.getSelector('Injectable'), + ); + const symbolClass = plugin.registerSymbol({ + exported: true, name: buildName({ config: { case: 'preserve', @@ -158,11 +148,11 @@ const generateAngularClassServices = ({ name: symbolInjectable.placeholder, } : undefined, - exportClass: currentClass.root, + exportClass: symbolClass.exported, name: symbolClass.placeholder, nodes: currentClass.nodes, }); - symbolClass.update({ value: node }); + plugin.setSymbolValue(symbolClass, node); generatedClasses.add(currentClass.className); }; @@ -177,15 +167,14 @@ const generateAngularFunctionServices = ({ }: { 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({ + const symbol = plugin.registerSymbol({ + exported: true, name: plugin.config.httpResources.methodNameBuilder(operation), }); const node = generateAngularResourceFunction({ @@ -194,7 +183,7 @@ const generateAngularFunctionServices = ({ plugin, symbol, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, node); }); }; @@ -205,30 +194,16 @@ const generateResourceCallExpression = ({ operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); - const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolHttpResource = f - .ensureSymbol({ - selector: plugin.api.getSelector('httpResource'), - }) - .update({ name: 'httpResource' }); - f.addImport({ - from: '@angular/common/http', - names: [symbolHttpResource.placeholder], - }); + const symbolHttpResource = plugin.referenceSymbol( + plugin.api.getSelector('httpResource'), + ); - const symbolResponseType = plugin.gen.selectSymbolFirst( + const symbolResponseType = plugin.getSymbol( pluginTypeScript.api.getSelector('response', operation.id), ); - if (symbolResponseType) { - f.addImport({ - from: symbolResponseType.file, - typeNames: [symbolResponseType.placeholder], - }); - } const responseType = symbolResponseType?.placeholder || 'unknown'; if (plugin.config.httpRequests.asClass) { @@ -243,24 +218,14 @@ const generateResourceCallExpression = ({ if (firstEntry) { // Import the root class from HTTP requests const rootClassName = firstEntry.path[0]!; - const symbolClass = plugin.gen.selectSymbolFirstOrThrow( + const symbolClass = plugin.referenceSymbol( 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], - }); + const symbolInject = plugin.referenceSymbol( + plugin.api.getSelector('inject'), + ); let methodAccess: ts.Expression = tsc.callExpression({ functionName: symbolInject.placeholder, parameters: [tsc.identifier({ text: symbolClass.placeholder })], @@ -319,13 +284,9 @@ const generateResourceCallExpression = ({ }); } } else { - const symbolHttpRequest = plugin.gen.selectSymbolFirstOrThrow( + const symbolHttpRequest = plugin.referenceSymbol( plugin.api.getSelector('httpRequest', operation.id), ); - f.addImport({ - from: symbolHttpRequest.file, - names: [symbolHttpRequest.placeholder], - }); return tsc.callExpression({ functionName: symbolHttpResource.placeholder, @@ -389,28 +350,16 @@ const generateAngularResourceMethod = ({ operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); - const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.getSelector('Options'), ); - f.addImport({ - from: symbolOptions.file, - typeNames: [symbolOptions.placeholder], - }); - const symbolDataType = plugin.gen.selectSymbolFirst( + const symbolDataType = plugin.getSymbol( pluginTypeScript.api.getSelector('data', operation.id), ); - if (symbolDataType) { - f.addImport({ - from: symbolDataType.file, - typeNames: [symbolDataType.placeholder], - }); - } const dataType = symbolDataType?.placeholder || 'unknown'; return tsc.methodDeclaration({ @@ -452,35 +401,23 @@ const generateAngularResourceFunction = ({ isRequiredOptions: boolean; operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; - symbol: ICodegenSymbolOut; + symbol: Symbol; }) => { - const f = plugin.gen.ensureFile(`${plugin.output}${pathSuffix}`); - const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.getSelector('Options'), ); - f.addImport({ - from: symbolOptions.file, - typeNames: [symbolOptions.placeholder], - }); - const symbolDataType = plugin.gen.selectSymbolFirst( + const symbolDataType = plugin.getSymbol( 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, + exportConst: symbol.exported, expression: tsc.arrowFunction({ parameters: [ { @@ -512,20 +449,9 @@ const generateAngularResourceFunction = ({ export const createHttpResources: AngularCommonPlugin['Handler'] = ({ plugin, }) => { - const f = plugin.gen.createFile(`${plugin.output}${pathSuffix}`, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - if (plugin.config.httpResources.asClass) { generateAngularClassServices({ plugin }); } else { generateAngularFunctionServices({ 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/plugin.ts b/packages/openapi-ts/src/plugins/@angular/common/plugin.ts index 477bb1a30..289723764 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/plugin.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/plugin.ts @@ -3,6 +3,30 @@ import { createHttpResources } from './httpResources'; import type { AngularCommonPlugin } from './types'; export const handler: AngularCommonPlugin['Handler'] = ({ plugin }) => { + plugin.registerSymbol({ + external: '@angular/common/http', + meta: { + kind: 'type', + }, + name: 'HttpRequest', + selector: plugin.api.getSelector('HttpRequest'), + }); + plugin.registerSymbol({ + external: '@angular/core', + name: 'inject', + selector: plugin.api.getSelector('inject'), + }); + plugin.registerSymbol({ + external: '@angular/core', + name: 'Injectable', + selector: plugin.api.getSelector('Injectable'), + }); + plugin.registerSymbol({ + external: '@angular/common/http', + name: 'httpResource', + selector: plugin.api.getSelector('httpResource'), + }); + if (plugin.config.httpRequests.enabled) { createHttpRequests({ 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 47830c53f..a7d7f73e7 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/types.d.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/types.d.ts @@ -2,153 +2,143 @@ import type { StringName } from '../../../types/case'; import type { DefinePlugin, Plugin } from '../../types'; import type { IApi } from './api'; -export type UserConfig = Plugin.Name<'@angular/common'> & { - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default false - */ - exportFromIndex?: boolean; - /** - * Options for generating HTTP Request instances. - * - * @default true - */ - httpRequests?: - | boolean - | { - /** - * Whether to generate the resource as a class. - * - * @default false - */ - asClass?: boolean; - /** - * Builds the class name for the generated resource. - * By default, the class name is suffixed with "Resources". - */ - classNameBuilder?: StringName; - /** - * Whether or not to create HTTP Request instances. - * - * @default true - */ - enabled?: boolean; - /** - * Builds the method name for the generated resource. - * - * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". - */ - methodNameBuilder?: (operation: IR.OperationObject) => string; - }; - /** - * Options for generating HTTP resource APIs. - * - * @default true - */ - httpResources?: - | boolean - | { - /** - * Whether to generate the resource as a class. - * @default false - */ - asClass?: boolean; - /** - * Builds the class name for the generated resource. - * By default, the class name is suffixed with "Resources". - */ - classNameBuilder?: StringName; - /** - * Whether or not to create HTTP resource APIs. - * - * @default true - */ - enabled?: boolean; - /** - * Builds the method name for the generated resource. - * - * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". - */ - methodNameBuilder?: (operation: IR.OperationObject) => string; - }; - /** - * Name of the generated file. - * - * @default '@angular/common' - */ - output?: string; -}; - -export type Config = Plugin.Name<'@angular/common'> & { - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default false - */ - exportFromIndex: boolean; - /** - * Options for generating HTTP Request instances. - */ - httpRequests: { +export type UserConfig = Plugin.Name<'@angular/common'> & + Plugin.Hooks & { /** - * Whether to generate the resource as a class. + * Should the exports from the generated files be re-exported in the index + * barrel file? * * @default false */ - asClass: boolean; - /** - * Builds the class name for the generated resource. - * By default, the class name is suffixed with "Resources". - */ - classNameBuilder: StringName; + exportFromIndex?: boolean; /** - * Whether or not to create HTTP Request instances. + * Options for generating HTTP Request instances. * * @default true */ - enabled: boolean; + httpRequests?: + | boolean + | { + /** + * Whether to generate the resource as a class. + * + * @default false + */ + asClass?: boolean; + /** + * Builds the class name for the generated resource. + * By default, the class name is suffixed with "Resources". + */ + classNameBuilder?: StringName; + /** + * Whether or not to create HTTP Request instances. + * + * @default true + */ + enabled?: boolean; + /** + * Builds the method name for the generated resource. + * + * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". + */ + methodNameBuilder?: (operation: IR.OperationObject) => string; + }; /** - * Builds the method name for the generated resource. - * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". + * Options for generating HTTP resource APIs. + * + * @default true */ - methodNameBuilder: (operation: IR.OperationObject) => string; + httpResources?: + | boolean + | { + /** + * Whether to generate the resource as a class. + * @default false + */ + asClass?: boolean; + /** + * Builds the class name for the generated resource. + * By default, the class name is suffixed with "Resources". + */ + classNameBuilder?: StringName; + /** + * Whether or not to create HTTP resource APIs. + * + * @default true + */ + enabled?: boolean; + /** + * Builds the method name for the generated resource. + * + * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". + */ + methodNameBuilder?: (operation: IR.OperationObject) => string; + }; }; - /** - * Options for generating HTTP resource APIs. - */ - httpResources: { + +export type Config = Plugin.Name<'@angular/common'> & + Plugin.Hooks & { /** - * Whether to generate the resource as a class. + * Should the exports from the generated files be re-exported in the index + * barrel file? * * @default false */ - asClass: boolean; - /** - * Builds the class name for the generated resource. - * By default, the class name is suffixed with "Resources". - */ - classNameBuilder: StringName; + exportFromIndex: boolean; /** - * Whether or not to create HTTP resource APIs. - * - * @default true + * Options for generating HTTP Request instances. */ - enabled: boolean; + httpRequests: { + /** + * Whether to generate the resource as a class. + * + * @default false + */ + asClass: boolean; + /** + * Builds the class name for the generated resource. + * By default, the class name is suffixed with "Resources". + */ + classNameBuilder: StringName; + /** + * Whether or not to create HTTP Request instances. + * + * @default true + */ + enabled: boolean; + /** + * Builds the method name for the generated resource. + * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". + */ + methodNameBuilder: (operation: IR.OperationObject) => string; + }; /** - * Builds the method name for the generated resource. - * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". + * Options for generating HTTP resource APIs. */ - methodNameBuilder: (operation: IR.OperationObject) => string; + httpResources: { + /** + * Whether to generate the resource as a class. + * + * @default false + */ + asClass: boolean; + /** + * Builds the class name for the generated resource. + * By default, the class name is suffixed with "Resources". + */ + classNameBuilder: StringName; + /** + * Whether or not to create HTTP resource APIs. + * + * @default true + */ + enabled: boolean; + /** + * Builds the method name for the generated resource. + * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource". + */ + methodNameBuilder: (operation: IR.OperationObject) => string; + }; }; - /** - * Name of the generated file. - * - * @default '@angular/common' - */ - output: string; -}; 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 index 163a1bdd9..5af4687d0 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -11,15 +11,13 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; 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)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 index 71da134b7..9414a28fe 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -11,15 +11,13 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; 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)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 d88c5ce9f..35c4ee0e9 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,6 +1,4 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; - -import { clientModulePath } from '../../../generate/client'; +import { clientFolderAbsolutePath } from '../../../generate/client'; import { tsc } from '../../../tsc'; import { parseUrl } from '../../../utils/url'; import type { PluginHandler } from './types'; @@ -29,45 +27,27 @@ const resolveBaseUrlString = ({ }; export const createClient: PluginHandler = ({ plugin }) => { - const f = plugin.gen.ensureFile(plugin.output); - - const clientModule = clientModulePath({ - config: plugin.context.config, - sourceOutput: f.path, - }); - const symbolCreateClient = f.addSymbol({ name: 'createClient' }); - f.addImport({ - aliases: { - [symbolCreateClient.name]: symbolCreateClient.placeholder, - }, - from: clientModule, - names: [symbolCreateClient.name], + const clientModule = clientFolderAbsolutePath(plugin.context.config); + const symbolCreateClient = plugin.registerSymbol({ + external: clientModule, + name: 'createClient', }); - const symbolCreateConfig = f.addSymbol({ name: 'createConfig' }); - f.addImport({ - aliases: { - [symbolCreateConfig.name]: symbolCreateConfig.placeholder, - }, - from: clientModule, - names: [symbolCreateConfig.name], + const symbolCreateConfig = plugin.registerSymbol({ + external: clientModule, + name: 'createConfig', }); const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolClientOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolClientOptions = plugin.referenceSymbol( pluginTypeScript.api.getSelector('ClientOptions'), ); - f.addImport({ - from: symbolClientOptions.file, - typeNames: [symbolClientOptions.placeholder], - }); - 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 { runtimeConfigPath } = plugin.config; + const symbolCreateClientConfig = runtimeConfigPath + ? plugin.registerSymbol({ + external: runtimeConfigPath, + name: 'createClientConfig', + }) + : undefined; const defaultValues: Array = []; @@ -111,7 +91,7 @@ export const createClient: PluginHandler = ({ plugin }) => { }), ]; - const symbolClient = f.addSymbol({ + const symbolClient = plugin.registerSymbol({ name: 'client', selector: plugin.api.getSelector('client'), }); @@ -130,5 +110,5 @@ export const createClient: PluginHandler = ({ plugin }) => { }), name: symbolClient.placeholder, }); - symbolClient.update({ value: statement }); + plugin.setSymbolValue(symbolClient, statement); }; diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/config.ts index a567dbad8..3457041ff 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/config.ts @@ -6,6 +6,5 @@ export const clientDefaultConfig = { export const clientDefaultMeta = { dependencies: ['@hey-api/typescript'], - output: 'client', tags: ['client'], } as const; 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 3e5ffa3ca..972f9b696 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,43 +1,41 @@ -import { clientModulePath } from '../../../generate/client'; +import { clientFolderAbsolutePath } from '../../../generate/client'; import { tsc } from '../../../tsc'; import type { PluginHandler } from './types'; export const createClientConfigType = ({ plugin, }: Parameters[0]) => { - const f = plugin.gen.ensureFile(plugin.output); - - const clientModule = clientModulePath({ - config: plugin.context.config, - sourceOutput: f.path, - }); + const clientModule = clientFolderAbsolutePath(plugin.context.config); const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolClientOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolClientOptions = plugin.referenceSymbol( pluginTypeScript.api.getSelector('ClientOptions'), ); - f.addImport({ - from: symbolClientOptions.file, - typeNames: [symbolClientOptions.placeholder], + const symbolConfig = plugin.registerSymbol({ + external: clientModule, + meta: { + kind: 'type', + }, + name: 'Config', }); - const symbolConfig = f.addSymbol({ name: 'Config' }); - const symbolDefaultClientOptions = f.addSymbol({ - name: 'DefaultClientOptions', + const symbolDefaultClientOptions = plugin.registerSymbol({ + external: clientModule, + meta: { + kind: 'type', + }, + name: 'ClientOptions', }); - f.addImport({ - aliases: { - ClientOptions: symbolDefaultClientOptions.placeholder, - [symbolConfig.name]: symbolConfig.placeholder, + const symbolCreateClientConfig = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', }, - from: clientModule, - typeNames: ['ClientOptions', symbolConfig.name], + name: 'CreateClientConfig', }); const defaultClientOptionsType = tsc.typeReferenceNode({ 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', @@ -47,7 +45,7 @@ export const createClientConfigType = ({ "`setConfig()`. This is useful for example if you're using Next.js", 'to ensure your client always has the correct values.', ], - exportType: true, + exportType: symbolCreateClientConfig.exported, name: symbolCreateClientConfig.placeholder, type: tsc.functionTypeNode({ parameters: [ @@ -89,5 +87,5 @@ export const createClientConfigType = ({ }, ], }); - symbolCreateClientConfig.update({ value: typeCreateClientConfig }); + plugin.setSymbolValue(symbolCreateClientConfig, 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 7b452df79..aac55bd1b 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,3 @@ -import { TypeScriptRenderer } from '../../../generate/renderer'; import { createClient } from './client'; import { createClientConfigType } from './createClientConfig'; import type { PluginHandler } from './types'; @@ -6,17 +5,6 @@ import type { PluginHandler } from './types'; export const clientPluginHandler = ({ plugin, }: Parameters[0]) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - 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 593fdf190..83c85223d 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 @@ -1,3 +1,4 @@ +import type { Plugin } from '../../types'; import type { HeyApiClientAngularPlugin } from '../client-angular'; import type { HeyApiClientAxiosPlugin } from '../client-axios'; import type { HeyApiClientFetchPlugin } from '../client-fetch'; @@ -16,7 +17,7 @@ export interface PluginHandler { * Public Client API. */ export namespace Client { - export type Config = { + export type Config = Plugin.Hooks & { /** * Set a default base URL when creating the client? You can set `baseUrl` * to a string which will be used as the base URL. If your input defines @@ -45,12 +46,6 @@ export namespace Client { * @default false */ exportFromIndex?: boolean; - /** - * Name of the generated file. - * - * @default 'client' - */ - output?: string; /** * Relative path to the runtime configuration file. This file must export * a `createClientConfig()` function. The `createClientConfig()` function 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 index 3b1233a7b..1a4e9f742 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -11,15 +11,13 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; 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)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 index f4de19160..0aa1c5e88 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -11,15 +11,13 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; 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)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 index cc0ed614b..ddb217aa1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -11,15 +11,13 @@ export type IApi = { * - `client`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; 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)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 da6f6864e..deff71a74 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 @@ -1,6 +1,6 @@ import fs from 'node:fs'; -import { CodegenProject } from '@hey-api/codegen-core'; +import { Project } from '@hey-api/codegen-core'; import type ts from 'typescript'; import { describe, expect, it, vi } from 'vitest'; @@ -36,7 +36,17 @@ describe('generateLegacySchemas', () => { }, name: 'AppClient', output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -141,7 +151,10 @@ describe('generateLegacySchemas', () => { }, context: {} as any, dependencies: [], - gen: new CodegenProject(), + gen: new Project({ + renderers: {}, + root: '.tmp', + }), handler: () => {}, name: '@hey-api/schemas', output: 'schemas', @@ -180,7 +193,17 @@ describe('generateLegacySchemas', () => { }, name: 'AppClient', output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -288,7 +311,10 @@ describe('generateLegacySchemas', () => { }, context: {} as any, dependencies: [], - gen: new CodegenProject(), + gen: new Project({ + renderers: {}, + root: '.tmp', + }), handler: () => {}, name: '@hey-api/schemas', output: 'schemas', diff --git a/packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts b/packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts index ad718d3b4..0deea2b62 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -11,15 +11,13 @@ export type IApi = { * - `ref`: `$ref` JSON pointer * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@hey-api/schemas'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 d01e5ee1e..55c9a8136 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/config.ts @@ -16,7 +16,6 @@ export const defaultConfig: HeyApiSchemasPlugin['Config'] = { handler, handlerLegacy, name: '@hey-api/schemas', - output: 'schemas', }; /** 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 e5d455774..b0b87b5b6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/schemas/plugin.ts @@ -1,4 +1,3 @@ -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'; @@ -367,8 +366,8 @@ 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({ + const symbol = plugin.registerSymbol({ + exported: true, name: schemaName({ name, plugin, schema }), selector: plugin.api.getSelector('ref', name), }); @@ -379,11 +378,11 @@ const schemasV2_0_X = ({ }); const statement = tsc.constVariable({ assertion: 'const', - exportConst: true, + exportConst: symbol.exported, expression: tsc.objectExpression({ obj }), name: symbol.placeholder, }); - symbol.update({ value: statement }); + plugin.setSymbolValue(symbol, statement); } }; @@ -400,8 +399,8 @@ 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({ + const symbol = plugin.registerSymbol({ + exported: true, name: schemaName({ name, plugin, schema }), selector: plugin.api.getSelector('ref', name), }); @@ -412,11 +411,11 @@ const schemasV3_0_X = ({ }); const statement = tsc.constVariable({ assertion: 'const', - exportConst: true, + exportConst: symbol.exported, expression: tsc.objectExpression({ obj }), name: symbol.placeholder, }); - symbol.update({ value: statement }); + plugin.setSymbolValue(symbol, statement); } }; @@ -433,8 +432,8 @@ 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({ + const symbol = plugin.registerSymbol({ + exported: true, name: schemaName({ name, plugin, schema }), selector: plugin.api.getSelector('ref', name), }); @@ -445,21 +444,15 @@ const schemasV3_1_X = ({ }); const statement = tsc.constVariable({ assertion: 'const', - exportConst: true, + exportConst: symbol.exported, expression: tsc.objectExpression({ obj }), name: symbol.placeholder, }); - symbol.update({ value: statement }); + plugin.setSymbolValue(symbol, statement); } }; export const handler: HeyApiSchemasPlugin['Handler'] = ({ plugin }) => { - plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - if ('swagger' in plugin.context.spec) { schemasV2_0_X({ context: plugin.context as IR.Context, 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 d094bb67f..fdffdd1ac 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 @@ -5,47 +5,42 @@ 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'> & { - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default false - */ - exportFromIndex?: boolean; - /** - * Customise the schema name. By default, `{{name}}Schema` is used. `name` is a - * valid JavaScript/TypeScript identifier, e.g. if your schema name is - * "Foo-Bar", `name` value would be "FooBar". - * - * @default '{{name}}Schema' - */ - nameBuilder?: - | string - | (( - name: string, - schema: - | OpenApiV2Schema - | OpenApiV3Schema - | OpenApiV2_0_XTypes['SchemaObject'] - | OpenApiV3_0_XTypes['ReferenceObject'] - | OpenApiV3_0_XTypes['SchemaObject'] - | OpenApiV3_1_XTypes['SchemaObject'], - ) => string); - /** - * Name of the generated file. - * - * @default 'schemas' - */ - output?: string; - /** - * Choose schema type to generate. Select 'form' if you don't want - * descriptions to reduce bundle size and you plan to use schemas - * for form validation - * - * @default 'json' - */ - type?: 'form' | 'json'; -}; +export type UserConfig = Plugin.Name<'@hey-api/schemas'> & + Plugin.Hooks & { + /** + * Should the exports from the generated files be re-exported in the index + * barrel file? + * + * @default false + */ + exportFromIndex?: boolean; + /** + * Customise the schema name. By default, `{{name}}Schema` is used. `name` is a + * valid JavaScript/TypeScript identifier, e.g. if your schema name is + * "Foo-Bar", `name` value would be "FooBar". + * + * @default '{{name}}Schema' + */ + nameBuilder?: + | string + | (( + name: string, + schema: + | OpenApiV2Schema + | OpenApiV3Schema + | OpenApiV2_0_XTypes['SchemaObject'] + | OpenApiV3_0_XTypes['ReferenceObject'] + | OpenApiV3_0_XTypes['SchemaObject'] + | OpenApiV3_1_XTypes['SchemaObject'], + ) => string); + /** + * Choose schema type to generate. Select 'form' if you don't want + * descriptions to reduce bundle size and you plan to use schemas + * for form validation + * + * @default 'json' + */ + type?: 'form' | 'json'; + }; export type HeyApiSchemasPlugin = DefinePlugin; 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 1804b5396..971228a2e 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 @@ -1,7 +1,7 @@ import fs from 'node:fs'; import path from 'node:path'; -import { CodegenProject } from '@hey-api/codegen-core'; +import { Project } from '@hey-api/codegen-core'; import type ts from 'typescript'; import { describe, expect, it, vi } from 'vitest'; @@ -38,7 +38,17 @@ describe('handlerLegacy', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -177,7 +187,10 @@ describe('handlerLegacy', () => { }, context: {} as any, dependencies: [], - gen: new CodegenProject(), + gen: new Project({ + renderers: {}, + root: '.tmp', + }), handler: () => {}, name: '@hey-api/sdk', output: '', @@ -255,7 +268,17 @@ describe('methodNameBuilder', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -356,7 +379,10 @@ describe('methodNameBuilder', () => { }, context: {} as any, dependencies: [], - gen: new CodegenProject(), + gen: new Project({ + renderers: {}, + root: '.tmp', + }), handler: () => {}, name: '@hey-api/sdk', output: '', @@ -394,7 +420,17 @@ describe('methodNameBuilder', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -496,7 +532,10 @@ describe('methodNameBuilder', () => { }, context: {} as any, dependencies: [], - gen: new CodegenProject(), + gen: new Project({ + renderers: {}, + root: '.tmp', + }), handler: () => {}, name: '@hey-api/sdk', output: '', @@ -536,7 +575,17 @@ describe('methodNameBuilder', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -638,7 +687,10 @@ describe('methodNameBuilder', () => { }, context: {} as any, dependencies: [], - gen: new CodegenProject(), + gen: new Project({ + renderers: {}, + root: '.tmp', + }), handler: () => {}, name: '@hey-api/sdk', output: '', diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts index 9ef79067c..b472c4829 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -6,8 +6,10 @@ type SelectorType = | 'buildClientParams' | 'class' | 'Client' + | 'Composable' | 'formDataBodySerializer' | 'function' + | 'Injectable' | 'Options' | 'urlSearchParamsBodySerializer'; @@ -18,21 +20,21 @@ export type IApi = { * - `buildClientParams`: never * - `class`: current class name * - `Client`: never + * - `Composable`: never * - `formDataBodySerializer`: never * - `function`: `operation.id` string + * - `Injectable`: never * - `Options`: never * - `urlSearchParamsBodySerializer`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@hey-api/sdk'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 9396cb2c0..967510fa5 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts @@ -27,7 +27,6 @@ export const defaultConfig: HeyApiSdkPlugin['Config'] = { handler, handlerLegacy, name: '@hey-api/sdk', - output: 'sdk', resolveConfig: (plugin, context) => { if (plugin.config.client) { if (typeof plugin.config.client === 'boolean') { 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 d4a2eb5a8..5615310ec 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,5 @@ -import type { ICodegenFile, ICodegenSymbolOut } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import { clientModulePath } from '../../../generate/client'; import { statusCodeToGroup } from '../../../ir/operation'; import type { IR } from '../../../ir/types'; import { sanitizeNamespaceIdentifier } from '../../../openApi'; @@ -13,7 +11,6 @@ import { stringCase } from '../../../utils/stringCase'; import { transformClassName } from '../../../utils/transform'; import type { Field, Fields } from '../client-core/bundle/params'; import { getClientPlugin } from '../client-core/utils'; -import type { PluginState } from '../typescript/types'; import { operationAuth } from './auth'; import { nuxtTypeComposable, nuxtTypeDefault } from './constants'; import type { HeyApiSdkPlugin } from './types'; @@ -148,12 +145,10 @@ export const operationClasses = ({ }; export const operationOptionsType = ({ - file, operation, plugin, throwOnError, }: { - file: ICodegenFile; operation: IR.OperationObject; plugin: HeyApiSdkPlugin['Instance']; throwOnError?: string; @@ -163,31 +158,19 @@ export const operationOptionsType = ({ const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolDataType = plugin.gen.selectSymbolFirst( + const symbolDataType = plugin.getSymbol( pluginTypeScript.api.getSelector('data', operation.id), ); - if (symbolDataType) { - file.addImport({ - from: symbolDataType.file, - typeNames: [symbolDataType.placeholder], - }); - } const dataType = symbolDataType?.placeholder || 'unknown'; - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( plugin.api.getSelector('Options'), ); if (isNuxtClient) { - const symbolResponseType = plugin.gen.selectSymbolFirst( + const symbolResponseType = plugin.getSymbol( 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}>`; } @@ -208,12 +191,10 @@ type OperationParameters = { }; export const operationParameters = ({ - file, isRequiredOptions, operation, plugin, }: { - file: ICodegenFile; isRequiredOptions: boolean; operation: IR.OperationObject; plugin: HeyApiSdkPlugin['Instance']; @@ -225,9 +206,6 @@ export const operationParameters = ({ }; const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const typescriptState: PluginState = { - usedTypeIDs: new Set(), - }; const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; @@ -246,15 +224,8 @@ export const operationParameters = ({ isRequired: parameter.required, name, type: pluginTypeScript.api.schemaToType({ - onRef: (symbol) => { - file.addImport({ - from: symbol.file, - typeNames: [symbol.placeholder], - }); - }, plugin: pluginTypeScript, schema: parameter.schema, - state: typescriptState, }), }); } @@ -274,15 +245,8 @@ export const operationParameters = ({ isRequired: parameter.required, name, type: pluginTypeScript.api.schemaToType({ - onRef: (symbol) => { - file.addImport({ - from: symbol.file, - typeNames: [symbol.placeholder], - }); - }, plugin: pluginTypeScript, schema: parameter.schema, - state: typescriptState, }), }); } @@ -297,15 +261,8 @@ export const operationParameters = ({ isRequired: operation.body.required, name, type: pluginTypeScript.api.schemaToType({ - onRef: (symbol) => { - file.addImport({ - from: symbol.file, - typeNames: [symbol.placeholder], - }); - }, plugin: pluginTypeScript, schema: operation.body.schema, - state: typescriptState, }), }); } @@ -316,7 +273,6 @@ export const operationParameters = ({ name: 'options', // TODO: ensure no path, body, query type: operationOptionsType({ - file, operation, plugin, throwOnError: isNuxtClient ? undefined : 'ThrowOnError', @@ -393,39 +349,25 @@ export const operationStatements = ({ operation: IR.OperationObject; plugin: HeyApiSdkPlugin['Instance']; }): Array => { - const f = plugin.gen.ensureFile(plugin.output); - const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolResponseType = plugin.gen.selectSymbolFirst( + const symbolResponseType = plugin.getSymbol( pluginTypeScript.api.getSelector( isNuxtClient ? 'response' : 'responses', operation.id, ), ); - if (symbolResponseType) { - f.addImport({ - from: symbolResponseType.file, - typeNames: [symbolResponseType.placeholder], - }); - } const responseType = symbolResponseType?.placeholder || 'unknown'; - const symbolErrorType = plugin.gen.selectSymbolFirst( + const symbolErrorType = plugin.getSymbol( 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 @@ -449,17 +391,9 @@ export const operationStatements = ({ if (operation.body) { switch (operation.body.type) { case 'form-data': { - const symbol = f.ensureSymbol({ - name: 'formDataBodySerializer', - selector: plugin.api.getSelector('formDataBodySerializer'), - }); - f.addImport({ - from: clientModulePath({ - config: plugin.context.config, - sourceOutput: f.path, - }), - names: [symbol.name], - }); + const symbol = plugin.referenceSymbol( + plugin.api.getSelector('formDataBodySerializer'), + ); requestOptions.push({ spread: symbol.placeholder }); break; } @@ -475,17 +409,9 @@ export const operationStatements = ({ }); break; case 'url-search-params': { - const symbol = f.ensureSymbol({ - name: 'urlSearchParamsBodySerializer', - selector: plugin.api.getSelector('urlSearchParamsBodySerializer'), - }); - f.addImport({ - from: clientModulePath({ - config: plugin.context.config, - sourceOutput: f.path, - }), - names: [symbol.name], - }); + const symbol = plugin.referenceSymbol( + plugin.api.getSelector('urlSearchParamsBodySerializer'), + ); requestOptions.push({ spread: symbol.placeholder }); break; } @@ -538,14 +464,13 @@ export const operationStatements = ({ const pluginTransformers = plugin.getPluginOrThrow( plugin.config.transformer, ); - const symbolResponseTransformer = plugin.gen.selectSymbolFirst( + const symbolResponseTransformer = plugin.getSymbol( pluginTransformers.api.getSelector('response', operation.id), ); - if (symbolResponseTransformer?.value) { - f.addImport({ - from: symbolResponseTransformer.file, - names: [symbolResponseTransformer.placeholder], - }); + if ( + symbolResponseTransformer && + plugin.getSymbolValue(symbolResponseTransformer) + ) { requestOptions.push({ key: 'responseTransformer', value: symbolResponseTransformer.placeholder, @@ -642,20 +567,9 @@ export const operationStatements = ({ } config.push(tsc.objectExpression({ obj })); } - const symbol = f.ensureSymbol({ - name: 'buildClientParams', - selector: plugin.api.getSelector('buildClientParams'), - }); - f.addImport({ - aliases: { - buildClientParams: symbol.placeholder, - }, - from: clientModulePath({ - config: plugin.context.config, - sourceOutput: f.path, - }), - names: ['buildClientParams'], - }); + const symbol = plugin.referenceSymbol( + plugin.api.getSelector('buildClientParams'), + ); statements.push( tsc.constVariable({ expression: tsc.callExpression({ @@ -708,19 +622,13 @@ export const operationStatements = ({ } } - 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 symbolClient = + plugin.config.client && client.api && 'getSelector' in client.api + ? plugin.getSymbol( + // @ts-expect-error + client.api.getSelector('client'), + ) + : undefined; const optionsClient = tsc.propertyAccessExpression({ expression: tsc.identifier({ text: 'options' }), 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 13850e90d..9493b7019 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts @@ -1,8 +1,6 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; import type ts from 'typescript'; -import { clientModulePath } from '../../../generate/client'; -import { TypeScriptRenderer } from '../../../generate/renderer'; +import { clientFolderAbsolutePath } from '../../../generate/client'; import { tsc } from '../../../tsc'; import { stringCase } from '../../../utils/stringCase'; import { @@ -39,19 +37,15 @@ const createClientClassNodes = ({ }), }); - const f = plugin.gen.ensureFile(plugin.output); - - const symbolClient = f.ensureSymbol({ - selector: plugin.api.getSelector('Client'), - }); + const symbolClient = plugin.referenceSymbol(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'), - ); - } + const symClient = + client.api && 'getSelector' in client.api + ? plugin.getSymbol( + // @ts-expect-error + client.api.getSelector('client'), + ) + : undefined; return [ tsc.propertyDeclaration({ @@ -135,7 +129,6 @@ 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 f = plugin.gen.ensureFile(plugin.output); const sdkClasses = new Map(); /** * Track unique added classes. @@ -152,18 +145,11 @@ const generateClassSdk = ({ operation, }); 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 symbolResponse = isNuxtClient + ? plugin.getSymbol( + pluginTypeScript.api.getSelector('response', operation.id), + ) + : undefined; const classes = operationClasses({ context: plugin.context, @@ -173,13 +159,12 @@ const generateClassSdk = ({ for (const entry of classes.values()) { entry.path.forEach((currentClassName, index) => { - const symbolCurrentClass = f.ensureSymbol({ - name: currentClassName, - selector: plugin.api.getSelector('class', currentClassName), - }); + const symbolCurrentClass = plugin.referenceSymbol( + plugin.api.getSelector('class', currentClassName), + ); if (!sdkClasses.has(symbolCurrentClass.id)) { sdkClasses.set(symbolCurrentClass.id, { - className: symbolCurrentClass.name, + className: currentClassName, classes: new Set(), id: symbolCurrentClass.id, methods: new Set(), @@ -190,10 +175,9 @@ const generateClassSdk = ({ const parentClassName = entry.path[index - 1]; if (parentClassName) { - const symbolParentClass = f.ensureSymbol({ - name: parentClassName, - selector: plugin.api.getSelector('class', parentClassName), - }); + const symbolParentClass = plugin.referenceSymbol( + plugin.api.getSelector('class', parentClassName), + ); if ( symbolParentClass.placeholder !== symbolCurrentClass.placeholder ) { @@ -217,7 +201,6 @@ const generateClassSdk = ({ } const opParameters = operationParameters({ - file: f, isRequiredOptions, operation, plugin, @@ -240,7 +223,10 @@ const generateClassSdk = ({ ? [ { default: tsc.ots.string('$fetch'), - extends: tsc.typeNode('Composable'), + extends: tsc.typeNode( + plugin.referenceSymbol(plugin.api.getSelector('Composable')) + .placeholder, + ), name: nuxtTypeComposable, }, { @@ -286,7 +272,10 @@ const generateClassSdk = ({ } }); - const symbolHeyApiClient = f.addSymbol({ name: '_HeyApiClient' }); + const symbolHeyApiClient = plugin.registerSymbol({ + exported: false, + name: '_HeyApiClient', + }); const generateClass = (currentClass: SdkClassEntry) => { if (generatedClasses.has(currentClass.id)) { @@ -319,11 +308,11 @@ const generateClassSdk = ({ ] : [], expression: tsc.identifier({ - text: f.getSymbolById(childClass.id)!.placeholder, + text: plugin.referenceSymbol(childClass.id).placeholder, }), }) : tsc.identifier({ - text: f.getSymbolById(childClass.id)!.placeholder, + text: plugin.referenceSymbol(childClass.id).placeholder, }), modifier: plugin.config.instance ? undefined : 'static', name: stringCase({ @@ -335,7 +324,8 @@ const generateClassSdk = ({ } } - const symbol = f.ensureSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, name: currentClass.className, selector: plugin.api.getSelector('class', currentClass.className), }); @@ -348,27 +338,28 @@ const generateClassSdk = ({ providedIn: 'root', }, ], - name: 'Injectable', + name: plugin.referenceSymbol(plugin.api.getSelector('Injectable')) + .placeholder, } : undefined, - exportClass: currentClass.root, + exportClass: symbol.exported, extendedClasses: plugin.config.instance ? [symbolHeyApiClient.placeholder] : undefined, name: symbol.placeholder, nodes: currentClass.nodes, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, node); generatedClasses.add(symbol.id); }; if (clientClassNodes.length) { const node = tsc.classDeclaration({ - exportClass: false, + exportClass: symbolHeyApiClient.exported, name: symbolHeyApiClient.placeholder, nodes: clientClassNodes, }); - symbolHeyApiClient.update({ value: node }); + plugin.setSymbolValue(symbolHeyApiClient, node); } for (const sdkClass of sdkClasses.values()) { @@ -383,7 +374,6 @@ const generateFlatSdk = ({ }) => { const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; - const f = plugin.gen.ensureFile(plugin.output); plugin.forEach('operation', ({ operation }) => { const isRequiredOptions = isOperationOptionsRequired({ @@ -391,20 +381,12 @@ const generateFlatSdk = ({ operation, }); 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 symbolResponse = isNuxtClient + ? plugin.getSymbol( + pluginTypeScript.api.getSelector('response', operation.id), + ) + : undefined; const opParameters = operationParameters({ - file: f, isRequiredOptions, operation, plugin, @@ -415,7 +397,7 @@ const generateFlatSdk = ({ operation, plugin, }); - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ name: serviceFunctionIdentifier({ config: plugin.context.config, handleIllegal: true, @@ -435,7 +417,10 @@ const generateFlatSdk = ({ ? [ { default: tsc.ots.string('$fetch'), - extends: tsc.typeNode('Composable'), + extends: tsc.typeNode( + plugin.referenceSymbol(plugin.api.getSelector('Composable')) + .placeholder, + ), name: nuxtTypeComposable, }, { @@ -465,52 +450,55 @@ const generateFlatSdk = ({ }), name: symbol.placeholder, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, node); }); }; export const handler: HeyApiSdkPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), + const clientModule = clientFolderAbsolutePath(plugin.context.config); + plugin.registerSymbol({ + external: clientModule, + name: 'formDataBodySerializer', + selector: plugin.api.getSelector('formDataBodySerializer'), }); - - // import required packages and core files - const clientModule = clientModulePath({ - config: plugin.context.config, - sourceOutput: f.path, + plugin.registerSymbol({ + external: clientModule, + name: 'urlSearchParamsBodySerializer', + selector: plugin.api.getSelector('urlSearchParamsBodySerializer'), }); - const symbolClientOptions = f.addSymbol({ name: 'ClientOptions' }); - f.addImport({ - aliases: { - Options: symbolClientOptions.placeholder, - }, - from: clientModule, - typeNames: ['Options'], + plugin.registerSymbol({ + external: clientModule, + name: 'buildClientParams', + selector: plugin.api.getSelector('buildClientParams'), }); const client = getClientPlugin(plugin.context.config); const isAngularClient = client.name === '@hey-api/client-angular'; const isNuxtClient = client.name === '@hey-api/client-nuxt'; if (isNuxtClient) { - f.addImport({ from: clientModule, typeNames: ['Composable'] }); + plugin.registerSymbol({ + external: clientModule, + meta: { + kind: 'type', + }, + name: 'Composable', + selector: plugin.api.getSelector('Composable'), + }); } if (isAngularClient && plugin.config.asClass) { - f.addImport({ from: '@angular/core', names: ['Injectable'] }); + plugin.registerSymbol({ + external: '@angular/core', + name: 'Injectable', + selector: plugin.api.getSelector('Injectable'), + }); } - createTypeOptions({ plugin, symbolClientOptions }); + createTypeOptions({ plugin }); 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 7f1edd5ac..15ddccb17 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/typeOptions.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/typeOptions.ts @@ -1,6 +1,4 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; - -import { clientModulePath } from '../../../generate/client'; +import { clientFolderAbsolutePath } from '../../../generate/client'; import { tsc } from '../../../tsc'; import { getClientPlugin } from '../client-core/utils'; import { nuxtTypeDefault, nuxtTypeResponse } from './constants'; @@ -8,34 +6,46 @@ import type { HeyApiSdkPlugin } from './types'; export const createTypeOptions = ({ plugin, - symbolClientOptions, }: { plugin: HeyApiSdkPlugin['Instance']; - symbolClientOptions: ICodegenSymbolOut; }) => { - const f = plugin.gen.ensureFile(plugin.output); + const clientModule = clientFolderAbsolutePath(plugin.context.config); const client = getClientPlugin(plugin.context.config); const isNuxtClient = client.name === '@hey-api/client-nuxt'; - const clientModule = clientModulePath({ - config: plugin.context.config, - sourceOutput: f.path, + const symbolTDataShape = plugin.registerSymbol({ + external: clientModule, + meta: { + kind: 'type', + }, + name: 'TDataShape', }); - const symbolTDataShape = f.addSymbol({ name: 'TDataShape' }); - const symbolClient = f.ensureSymbol({ + const symbolClient = plugin.registerSymbol({ + external: clientModule, + meta: { + kind: 'type', + }, name: 'Client', selector: plugin.api.getSelector('Client'), }); - f.addImport({ - from: clientModule, - typeNames: [symbolClient.name, symbolTDataShape.name], + const symbolClientOptions = plugin.registerSymbol({ + external: clientModule, + meta: { + kind: 'type', + }, + name: 'Options', + }); + const symbolOptions = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: 'Options', + selector: plugin.api.getSelector('Options'), }); - const symbolOptions = f - .ensureSymbol({ selector: plugin.api.getSelector('Options') }) - .update({ name: 'Options' }); const typeOptions = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolOptions.exported, name: symbolOptions.placeholder, type: tsc.typeIntersectionNode({ types: [ @@ -90,7 +100,11 @@ export const createTypeOptions = ({ typeParameters: isNuxtClient ? [ tsc.typeParameterDeclaration({ - constraint: tsc.typeReferenceNode({ typeName: 'Composable' }), + constraint: tsc.typeReferenceNode({ + typeName: plugin.referenceSymbol( + plugin.api.getSelector('Composable'), + ).placeholder, + }), defaultType: tsc.typeNode("'$fetch'"), name: 'TComposable', }), @@ -129,5 +143,5 @@ export const createTypeOptions = ({ }), ], }); - symbolOptions.update({ value: typeOptions }); + plugin.setSymbolValue(symbolOptions, 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 d83fd1b55..ffd5d7ad7 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 @@ -9,333 +9,323 @@ import type { } from '../../types'; import type { IApi } from './api'; -export type UserConfig = Plugin.Name<'@hey-api/sdk'> & { - /** - * Group operation methods into classes? When enabled, you can select which - * classes to export with `sdk.include` and/or transform their names with - * `sdk.classNameBuilder`. - * - * Note that by enabling this option, your SDKs will **NOT** - * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}. - * For this reason, it is disabled by default. - * - * @default false - */ - asClass?: boolean; - /** - * Should the generated functions contain auth mechanisms? You may want to - * disable this option if you're handling auth yourself or defining it - * globally on the client and want to reduce the size of generated code. - * - * @default true - */ - auth?: boolean; - /** - * Customize the generated class names. The name variable is obtained from - * your OpenAPI specification tags or `instance` value. - * - * This option has no effect if `sdk.asClass` is `false`. - */ - classNameBuilder?: StringName; - /** - * How should we structure your SDK? By default, we try to infer the ideal - * structure using `operationId` keywords. If you prefer a flatter structure, - * you can set `classStructure` to `off` to disable this behavior. - * - * @default 'auto' - */ - classStructure?: 'auto' | 'off'; - /** - * Use an internal client instance to send HTTP requests? This is useful if - * you don't want to manually pass the client to each SDK function. - * - * You can customize the selected client output through its plugin. You can - * also set `client` to `true` to automatically choose the client from your - * defined plugins. If we can't detect a client plugin when using `true`, we - * will default to `@hey-api/client-fetch`. - * - * @default true - */ - client?: PluginClientNames | boolean; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default true - */ - exportFromIndex?: boolean; - /** - * Include only service classes with names matching regular expression - * - * This option has no effect if `sdk.asClass` is `false`. - */ - include?: string; - /** - * Set `instance` to create an instantiable SDK. Using `true` will use the - * default instance name; in practice, you want to define your own by passing - * a string value. - * - * @default false - */ - instance?: string | boolean; - /** - * Customise the name of methods within the service. By default, - * {@link IR.OperationObject.id} or {@link Operation.name} is used. - */ - methodNameBuilder?: (operation: IR.OperationObject | Operation) => string; - // TODO: parser - rename operationId option to something like inferId?: boolean - /** - * Use operation ID to generate operation names? - * - * @default true - */ - operationId?: boolean; - /** - * Name of the generated file. - * - * @default 'sdk' - */ - output?: string; - /** @deprecated - this is an experimental feature, do not use */ - params_EXPERIMENTAL?: 'default' | 'experiment'; - /** - * **This feature works only with the Fetch client** - * - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ - responseStyle?: 'data' | 'fields'; - /** - * Transform response data before returning. This is useful if you want to - * convert for example ISO strings into Date objects. However, transformation - * adds runtime overhead, so it's not recommended to use unless necessary. - * - * You can customize the selected transformer output through its plugin. You - * can also set `transformer` to `true` to automatically choose the - * transformer from your defined plugins. - * - * @default false - */ - transformer?: '@hey-api/transformers' | boolean; - /** - * Validate request and/or response data against schema before returning. - * This is useful if you want to ensure the request and/or response conforms - * to a desired shape. However, validation adds runtime overhead, so it's - * not recommended to use unless absolutely necessary. - * - * You can customize the validator output through its plugin. You can also - * set `validator` to `true` to automatically choose the validator from your - * defined plugins. - * - * You can enable/disable validation for requests and responses separately - * by setting `validator` to an object `{ request, response }`. - * - * Ensure you have declared the selected library as a dependency to avoid - * errors. - * - * @default false - */ - validator?: - | PluginValidatorNames - | boolean - | { - /** - * Validate request data against schema before sending. - * - * Can be a validator plugin name or boolean (true to auto-select, false - * to disable). - * - * @default false - */ - request?: PluginValidatorNames | boolean; - /** - * Validate response data against schema before returning. - * - * Can be a validator plugin name or boolean (true to auto-select, false - * to disable). - * - * @default false - */ - response?: PluginValidatorNames | boolean; - }; +export type UserConfig = Plugin.Name<'@hey-api/sdk'> & + Plugin.Hooks & { + /** + * Group operation methods into classes? When enabled, you can select which + * classes to export with `sdk.include` and/or transform their names with + * `sdk.classNameBuilder`. + * + * Note that by enabling this option, your SDKs will **NOT** + * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}. + * For this reason, it is disabled by default. + * + * @default false + */ + asClass?: boolean; + /** + * Should the generated functions contain auth mechanisms? You may want to + * disable this option if you're handling auth yourself or defining it + * globally on the client and want to reduce the size of generated code. + * + * @default true + */ + auth?: boolean; + /** + * Customize the generated class names. The name variable is obtained from + * your OpenAPI specification tags or `instance` value. + * + * This option has no effect if `sdk.asClass` is `false`. + */ + classNameBuilder?: StringName; + /** + * How should we structure your SDK? By default, we try to infer the ideal + * structure using `operationId` keywords. If you prefer a flatter structure, + * you can set `classStructure` to `off` to disable this behavior. + * + * @default 'auto' + */ + classStructure?: 'auto' | 'off'; + /** + * Use an internal client instance to send HTTP requests? This is useful if + * you don't want to manually pass the client to each SDK function. + * + * You can customize the selected client output through its plugin. You can + * also set `client` to `true` to automatically choose the client from your + * defined plugins. If we can't detect a client plugin when using `true`, we + * will default to `@hey-api/client-fetch`. + * + * @default true + */ + client?: PluginClientNames | boolean; + /** + * Should the exports from the generated files be re-exported in the index + * barrel file? + * + * @default true + */ + exportFromIndex?: boolean; + /** + * Include only service classes with names matching regular expression + * + * This option has no effect if `sdk.asClass` is `false`. + */ + include?: string; + /** + * Set `instance` to create an instantiable SDK. Using `true` will use the + * default instance name; in practice, you want to define your own by passing + * a string value. + * + * @default false + */ + instance?: string | boolean; + /** + * Customise the name of methods within the service. By default, + * {@link IR.OperationObject.id} or {@link Operation.name} is used. + */ + methodNameBuilder?: (operation: IR.OperationObject | Operation) => string; + // TODO: parser - rename operationId option to something like inferId?: boolean + /** + * Use operation ID to generate operation names? + * + * @default true + */ + operationId?: boolean; + /** @deprecated - this is an experimental feature, do not use */ + params_EXPERIMENTAL?: 'default' | 'experiment'; + /** + * **This feature works only with the Fetch client** + * + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle?: 'data' | 'fields'; + /** + * Transform response data before returning. This is useful if you want to + * convert for example ISO strings into Date objects. However, transformation + * adds runtime overhead, so it's not recommended to use unless necessary. + * + * You can customize the selected transformer output through its plugin. You + * can also set `transformer` to `true` to automatically choose the + * transformer from your defined plugins. + * + * @default false + */ + transformer?: '@hey-api/transformers' | boolean; + /** + * Validate request and/or response data against schema before returning. + * This is useful if you want to ensure the request and/or response conforms + * to a desired shape. However, validation adds runtime overhead, so it's + * not recommended to use unless absolutely necessary. + * + * You can customize the validator output through its plugin. You can also + * set `validator` to `true` to automatically choose the validator from your + * defined plugins. + * + * You can enable/disable validation for requests and responses separately + * by setting `validator` to an object `{ request, response }`. + * + * Ensure you have declared the selected library as a dependency to avoid + * errors. + * + * @default false + */ + validator?: + | PluginValidatorNames + | boolean + | { + /** + * Validate request data against schema before sending. + * + * Can be a validator plugin name or boolean (true to auto-select, false + * to disable). + * + * @default false + */ + request?: PluginValidatorNames | boolean; + /** + * Validate response data against schema before returning. + * + * Can be a validator plugin name or boolean (true to auto-select, false + * to disable). + * + * @default false + */ + response?: PluginValidatorNames | boolean; + }; - // DEPRECATED OPTIONS BELOW + // DEPRECATED OPTIONS BELOW - /** - * **This feature works only with the legacy parser** - * - * Filter endpoints to be included in the generated SDK. The provided - * string should be a regular expression where matched results will be - * included in the output. The input pattern this string will be tested - * against is `{method} {path}`. For example, you can match - * `POST /api/v1/foo` with `^POST /api/v1/foo$`. - * - * @deprecated - */ - // eslint-disable-next-line typescript-sort-keys/interface - filter?: string; - /** - * Define shape of returned value from service calls - * - * @deprecated - * @default 'body' - */ - response?: 'body' | 'response'; -}; + /** + * **This feature works only with the legacy parser** + * + * Filter endpoints to be included in the generated SDK. The provided + * string should be a regular expression where matched results will be + * included in the output. The input pattern this string will be tested + * against is `{method} {path}`. For example, you can match + * `POST /api/v1/foo` with `^POST /api/v1/foo$`. + * + * @deprecated + */ + // eslint-disable-next-line typescript-sort-keys/interface + filter?: string; + /** + * Define shape of returned value from service calls + * + * @deprecated + * @default 'body' + */ + response?: 'body' | 'response'; + }; -export type Config = Plugin.Name<'@hey-api/sdk'> & { - /** - * Group operation methods into classes? When enabled, you can select which - * classes to export with `sdk.include` and/or transform their names with - * `sdk.classNameBuilder`. - * - * Note that by enabling this option, your SDKs will **NOT** - * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}. - * For this reason, it is disabled by default. - * - * @default false - */ - asClass: boolean; - /** - * Should the generated functions contain auth mechanisms? You may want to - * disable this option if you're handling auth yourself or defining it - * globally on the client and want to reduce the size of generated code. - * - * @default true - */ - auth: boolean; - /** - * Customize the generated class names. The name variable is obtained from - * your OpenAPI specification tags or `instance` value. - * - * This option has no effect if `sdk.asClass` is `false`. - */ - classNameBuilder: StringName; - /** - * How should we structure your SDK? By default, we try to infer the ideal - * structure using `operationId` keywords. If you prefer a flatter structure, - * you can set `classStructure` to `off` to disable this behavior. - * - * @default 'auto' - */ - classStructure: 'auto' | 'off'; - /** - * Use an internal client instance to send HTTP requests? This is useful if - * you don't want to manually pass the client to each SDK function. - * - * You can customize the selected client output through its plugin. You can - * also set `client` to `true` to automatically choose the client from your - * defined plugins. If we can't detect a client plugin when using `true`, we - * will default to `@hey-api/client-fetch`. - * - * @default true - */ - client: PluginClientNames | false; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default true - */ - exportFromIndex: boolean; - /** - * Include only service classes with names matching regular expression - * - * This option has no effect if `sdk.asClass` is `false`. - */ - include: string | undefined; - /** - * Set `instance` to create an instantiable SDK. Using `true` will use the - * default instance name; in practice, you want to define your own by passing - * a string value. - * - * @default false - */ - instance: string | boolean; - /** - * Customise the name of methods within the service. By default, - * {@link IR.OperationObject.id} or {@link Operation.name} is used. - */ - methodNameBuilder?: (operation: IR.OperationObject | Operation) => string; - // TODO: parser - rename operationId option to something like inferId?: boolean - /** - * Use operation ID to generate operation names? - * - * @default true - */ - operationId: boolean; - /** - * Name of the generated file. - * - * @default 'sdk' - */ - output: string; - /** @deprecated - this is an experimental feature, do not use */ - params_EXPERIMENTAL: 'default' | 'experiment'; - /** - * **This feature works only with the Fetch client** - * - * Should we return only data or multiple fields (data, error, response, etc.)? - * - * @default 'fields' - */ - responseStyle: 'data' | 'fields'; - /** - * Transform response data before returning. This is useful if you want to - * convert for example ISO strings into Date objects. However, transformation - * adds runtime overhead, so it's not recommended to use unless necessary. - * - * You can customize the selected transformer output through its plugin. You - * can also set `transformer` to `true` to automatically choose the - * transformer from your defined plugins. - * - * @default false - */ - transformer: '@hey-api/transformers' | false; - /** - * Validate request and/or response data against schema before returning. - * This is useful if you want to ensure the request and/or response conforms - * to a desired shape. However, validation adds runtime overhead, so it's - * not recommended to use unless absolutely necessary. - */ - validator: { +export type Config = Plugin.Name<'@hey-api/sdk'> & + Plugin.Hooks & { /** - * The validator plugin to use for request validation, or false to disable. + * Group operation methods into classes? When enabled, you can select which + * classes to export with `sdk.include` and/or transform their names with + * `sdk.classNameBuilder`. + * + * Note that by enabling this option, your SDKs will **NOT** + * support {@link https://developer.mozilla.org/docs/Glossary/Tree_shaking tree-shaking}. + * For this reason, it is disabled by default. * * @default false */ - request: PluginValidatorNames | false; + asClass: boolean; + /** + * Should the generated functions contain auth mechanisms? You may want to + * disable this option if you're handling auth yourself or defining it + * globally on the client and want to reduce the size of generated code. + * + * @default true + */ + auth: boolean; + /** + * Customize the generated class names. The name variable is obtained from + * your OpenAPI specification tags or `instance` value. + * + * This option has no effect if `sdk.asClass` is `false`. + */ + classNameBuilder: StringName; + /** + * How should we structure your SDK? By default, we try to infer the ideal + * structure using `operationId` keywords. If you prefer a flatter structure, + * you can set `classStructure` to `off` to disable this behavior. + * + * @default 'auto' + */ + classStructure: 'auto' | 'off'; + /** + * Use an internal client instance to send HTTP requests? This is useful if + * you don't want to manually pass the client to each SDK function. + * + * You can customize the selected client output through its plugin. You can + * also set `client` to `true` to automatically choose the client from your + * defined plugins. If we can't detect a client plugin when using `true`, we + * will default to `@hey-api/client-fetch`. + * + * @default true + */ + client: PluginClientNames | false; + /** + * Should the exports from the generated files be re-exported in the index + * barrel file? + * + * @default true + */ + exportFromIndex: boolean; + /** + * Include only service classes with names matching regular expression + * + * This option has no effect if `sdk.asClass` is `false`. + */ + include: string | undefined; /** - * The validator plugin to use for response validation, or false to disable. + * Set `instance` to create an instantiable SDK. Using `true` will use the + * default instance name; in practice, you want to define your own by passing + * a string value. * * @default false */ - response: PluginValidatorNames | false; - }; + instance: string | boolean; + /** + * Customise the name of methods within the service. By default, + * {@link IR.OperationObject.id} or {@link Operation.name} is used. + */ + methodNameBuilder?: (operation: IR.OperationObject | Operation) => string; + // TODO: parser - rename operationId option to something like inferId?: boolean + /** + * Use operation ID to generate operation names? + * + * @default true + */ + operationId: boolean; + /** @deprecated - this is an experimental feature, do not use */ + params_EXPERIMENTAL: 'default' | 'experiment'; + /** + * **This feature works only with the Fetch client** + * + * Should we return only data or multiple fields (data, error, response, etc.)? + * + * @default 'fields' + */ + responseStyle: 'data' | 'fields'; + /** + * Transform response data before returning. This is useful if you want to + * convert for example ISO strings into Date objects. However, transformation + * adds runtime overhead, so it's not recommended to use unless necessary. + * + * You can customize the selected transformer output through its plugin. You + * can also set `transformer` to `true` to automatically choose the + * transformer from your defined plugins. + * + * @default false + */ + transformer: '@hey-api/transformers' | false; + /** + * Validate request and/or response data against schema before returning. + * This is useful if you want to ensure the request and/or response conforms + * to a desired shape. However, validation adds runtime overhead, so it's + * not recommended to use unless absolutely necessary. + */ + validator: { + /** + * The validator plugin to use for request validation, or false to disable. + * + * @default false + */ + request: PluginValidatorNames | false; + /** + * The validator plugin to use for response validation, or false to disable. + * + * @default false + */ + response: PluginValidatorNames | false; + }; - // DEPRECATED OPTIONS BELOW + // DEPRECATED OPTIONS BELOW - /** - * **This feature works only with the legacy parser** - * - * Filter endpoints to be included in the generated SDK. The provided - * string should be a regular expression where matched results will be - * included in the output. The input pattern this string will be tested - * against is `{method} {path}`. For example, you can match - * `POST /api/v1/foo` with `^POST /api/v1/foo$`. - * - * @deprecated - */ - // eslint-disable-next-line typescript-sort-keys/interface - filter?: string; - /** - * Define shape of returned value from service calls - * - * @deprecated - * @default 'body' - */ - response: 'body' | 'response'; -}; + /** + * **This feature works only with the legacy parser** + * + * Filter endpoints to be included in the generated SDK. The provided + * string should be a regular expression where matched results will be + * included in the output. The input pattern this string will be tested + * against is `{method} {path}`. For example, you can match + * `POST /api/v1/foo` with `^POST /api/v1/foo$`. + * + * @deprecated + */ + // eslint-disable-next-line typescript-sort-keys/interface + filter?: string; + /** + * Define shape of returned value from service calls + * + * @deprecated + * @default 'body' + */ + response: 'body' | 'response'; + }; 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 8cfd735ea..714207fb9 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/validator.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/validator.ts @@ -18,7 +18,6 @@ export const createRequestValidator = ({ if (!validator.api.createRequestValidator) return; return validator.api.createRequestValidator({ - file: plugin.gen.ensureFile(plugin.output), operation, // @ts-expect-error plugin: validator, @@ -35,7 +34,6 @@ export const createResponseValidator = ({ if (!validator.api.createResponseValidator) return; return validator.api.createResponseValidator({ - file: plugin.gen.ensureFile(plugin.output), operation, // @ts-expect-error 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 index 8fbf60bf9..920c22e80 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -12,15 +12,13 @@ export type IApi = { * - `response-ref`: `$ref` JSON pointer * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@hey-api/transformers'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 7eeb61cd5..53a7ef0ae 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/config.ts @@ -20,7 +20,6 @@ export const defaultConfig: HeyApiTransformersPlugin['Config'] = { handler, handlerLegacy, name: '@hey-api/transformers', - output: 'transformers', resolveConfig: (plugin) => { if (!plugin.config.transformers) { plugin.config.transformers = []; 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 b21d59a79..4e1e94971 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/expressions.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/expressions.ts @@ -1,4 +1,3 @@ -import type { ICodegenFile } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { IR } from '../../../ir/types'; @@ -8,12 +7,10 @@ import type { UserConfig } from './types'; export type ExpressionTransformer = ({ config, dataExpression, - file, schema, }: { config: Omit; dataExpression?: ts.Expression | string; - 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 18261c3d5..aa203c16f 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/transformers/plugin.ts @@ -1,6 +1,5 @@ import ts from 'typescript'; -import { TypeScriptRenderer } from '../../../generate/renderer'; import { createOperationKey, operationResponsesMap, @@ -60,14 +59,11 @@ const processSchemaType = ({ plugin: HeyApiTransformersPlugin['Instance']; schema: IR.SchemaObject; }): Array => { - const f = plugin.gen.ensureFile(plugin.output); - if (schema.$ref) { const selector = plugin.api.getSelector('response-ref', schema.$ref); - let symbolResponseTransformerRef = f.selectSymbolFirst(selector); - if (!symbolResponseTransformerRef) { - symbolResponseTransformerRef = f.addSymbol({ + if (!plugin.getSymbol(selector)) { + const symbol = plugin.registerSymbol({ name: buildName({ config: { case: 'camelCase', @@ -100,18 +96,18 @@ const processSchemaType = ({ ], statements: ensureStatements(nodes), }), - name: symbolResponseTransformerRef.placeholder, + name: symbol.placeholder, }); - symbolResponseTransformerRef.update({ value: node }); + plugin.setSymbolValue(symbol, node); } else { // the created schema response transformer was empty, do not generate // it and prevent any future attempts - symbolResponseTransformerRef.update({ value: null }); + plugin.setSymbolValue(symbol, null); } } - symbolResponseTransformerRef = f.selectSymbolFirst(selector); - if (symbolResponseTransformerRef?.value) { + const symbolResponseTransformerRef = plugin.referenceSymbol(selector); + if (plugin.getSymbolValue(symbolResponseTransformerRef) !== null) { const callExpression = tsc.callExpression({ functionName: symbolResponseTransformerRef.placeholder, parameters: [dataExpression], @@ -314,7 +310,6 @@ const processSchemaType = ({ const t = transformer({ config: plugin.config, dataExpression, - file: f, schema, }); if (t) { @@ -327,12 +322,6 @@ const processSchemaType = ({ // handles only response transformers for now export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - plugin.forEach('operation', ({ operation }) => { const { response } = operationResponsesMap(operation); if (!response) return; @@ -347,13 +336,13 @@ export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { } const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolResponse = plugin.gen.selectSymbolFirst( + const symbolResponse = plugin.getSymbol( pluginTypeScript.api.getSelector('response', operation.id), ); - if (!symbolResponse) return; - const symbolResponseTransformer = f.addSymbol({ + const symbolResponseTransformer = plugin.registerSymbol({ + exported: true, name: buildName({ config: { case: 'camelCase', @@ -367,12 +356,8 @@ export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { // TODO: parser - consider handling simple string response which is also a date const nodes = schemaResponseTransformerNodes({ plugin, schema: response }); if (nodes.length) { - f.addImport({ - from: symbolResponse.file, - typeNames: [symbolResponse.placeholder], - }); const responseTransformerNode = tsc.constVariable({ - exportConst: true, + exportConst: symbolResponseTransformer.exported, expression: tsc.arrowFunction({ async: true, multiLine: true, @@ -393,9 +378,9 @@ export const handler: HeyApiTransformersPlugin['Handler'] = ({ plugin }) => { }), name: symbolResponseTransformer.placeholder, }); - symbolResponseTransformer.update({ value: responseTransformerNode }); + plugin.setSymbolValue(symbolResponseTransformer, responseTransformerNode); } else { - symbolResponseTransformer.update({ value: null }); + plugin.setSymbolValue(symbolResponseTransformer, 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 c14b4edad..5ac02deac 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,4 +1,3 @@ -import type { ICodegenFile } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { IR } from '../../../ir/types'; @@ -11,83 +10,71 @@ import type { ExpressionTransformer } from './expressions'; * If undefined is returned, the default type will be used. */ export type TypeTransformer = ({ - file, schema, }: { - file: ICodegenFile; schema: IR.SchemaObject; }) => ts.TypeNode | undefined; -export type UserConfig = 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 UserConfig = Plugin.Name<'@hey-api/transformers'> & + Plugin.Hooks & { + /** + * 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; + /** + * Custom transforms to apply to the generated code. + */ + transformers?: ReadonlyArray; + /** + * Custom type transformers that modify the TypeScript types generated. + */ + typeTransformers?: ReadonlyArray; + }; -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 Config = Plugin.Name<'@hey-api/transformers'> & + Plugin.Hooks & { + /** + * 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; + /** + * 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/__tests__/plugin.test.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/__tests__/plugin.test.ts index 547a55dbb..a01dcea79 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 @@ -1,6 +1,6 @@ import fs from 'node:fs'; -import { CodegenProject } from '@hey-api/codegen-core'; +import { Project } from '@hey-api/codegen-core'; import type ts from 'typescript'; import { describe, expect, it, vi } from 'vitest'; @@ -36,7 +36,17 @@ describe('generateLegacyTypes', () => { }, name: 'AppClient', output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -170,7 +180,10 @@ describe('generateLegacyTypes', () => { }, context: {} as any, dependencies: [], - gen: new CodegenProject(), + gen: new Project({ + renderers: {}, + root: '.tmp', + }), handler: () => {}, name: '@hey-api/typescript', output: '', 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 2513cee15..9ddaef171 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { Plugin } from '../../types'; @@ -12,13 +12,11 @@ type SelectorType = | 'ref' | 'response' | 'responses' + | 'TypeID' | 'webhook-payload' | 'webhook-request' | 'Webhooks'; -type SchemaToTypeArgs = Omit[0], 'onRef'> & - Pick[0]>, 'onRef'>; - export type IApi = { /** * @param type Selector type. @@ -30,25 +28,24 @@ export type IApi = { * - `ref`: `$ref` JSON pointer * - `response`: `operation.id` string * - `responses`: `operation.id` string + * - `TypeID`: `type` name 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; + getSelector: (type: SelectorType, value?: string) => Selector; + schemaToType: (args: Parameters[0]) => ts.TypeNode; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@hey-api/typescript'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } - schemaToType(args: SchemaToTypeArgs): ts.TypeNode { - return schemaToType({ onRef: undefined, ...args }); + schemaToType(args: Parameters[0]): ts.TypeNode { + return schemaToType(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 5500d8f82..eafcc5e40 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/clientOptions.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/clientOptions.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import ts from 'typescript'; import type { IR } from '../../../ir/types'; @@ -36,7 +36,7 @@ export const createClientOptions = ({ }: { plugin: HeyApiTypeScriptPlugin['Instance']; servers: ReadonlyArray; - symbolClientOptions: ICodegenSymbolOut; + symbolClientOptions: Symbol; }) => { const client = getClientPlugin(plugin.context.config); @@ -66,9 +66,9 @@ export const createClientOptions = ({ useLegacyResolution: false, }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolClientOptions.exported, name: symbolClientOptions.placeholder, type, }); - symbolClientOptions.update({ value: node }); + plugin.setSymbolValue(symbolClientOptions, 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 b812d7857..ac3575b97 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/config.ts @@ -18,7 +18,6 @@ export const defaultConfig: HeyApiTypeScriptPlugin['Config'] = { handler, handlerLegacy, name: '@hey-api/typescript', - output: 'types', resolveConfig: (plugin, context) => { plugin.config.definitions = context.valueToObject({ defaultValue: { diff --git a/packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts b/packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts index 7908f08fb..13171b12c 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/export.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { IR } from '../../../ir/types'; @@ -88,7 +88,7 @@ export const exportType = ({ }: { plugin: HeyApiTypeScriptPlugin['Instance']; schema: IR.SchemaObject; - symbol: ICodegenSymbolOut; + symbol: Symbol; type: ts.TypeNode; }) => { // root enums have an additional export @@ -130,8 +130,7 @@ export const exportType = ({ objectType: typeofType, }), }); - - symbol.update({ value: [objectNode, node] }); + plugin.setSymbolValue(symbol, [objectNode, node]); return; } else if ( plugin.config.enums.mode === 'typescript' || @@ -148,7 +147,7 @@ export const exportType = ({ name: symbol.placeholder, obj: enumObject.obj, }); - symbol.update({ value: enumNode }); + plugin.setSymbolValue(symbol, enumNode); return; } } @@ -156,9 +155,9 @@ export const exportType = ({ const node = tsc.typeAliasDeclaration({ comment: createSchemaComment({ schema }), - exportType: true, + exportType: symbol.exported, name: symbol.placeholder, type, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, 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 75c27d05f..b2be1fa9a 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/operation.ts @@ -4,7 +4,7 @@ import type { IR } from '../../../ir/types'; import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { schemaToType } from './plugin'; -import type { HeyApiTypeScriptPlugin, PluginState } from './types'; +import type { HeyApiTypeScriptPlugin } from './types'; const irParametersToIrSchema = ({ parameters, @@ -45,11 +45,9 @@ const irParametersToIrSchema = ({ const operationToDataType = ({ operation, plugin, - state, }: { operation: IR.OperationObject; plugin: HeyApiTypeScriptPlugin['Instance']; - state: PluginState; }) => { const data: IR.SchemaObject = { type: 'object', @@ -121,8 +119,11 @@ const operationToDataType = ({ data.required = dataRequired; - const f = plugin.gen.ensureFile(plugin.output); - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.requests, name: operation.id, @@ -130,37 +131,35 @@ const operationToDataType = ({ selector: plugin.api.getSelector('data', operation.id), }); const type = schemaToType({ - onRef: undefined, plugin, schema: data, - state, }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbol.exported, name: symbol.placeholder, type, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, node); }; export const operationToType = ({ operation, plugin, - state, }: { operation: IR.OperationObject; plugin: HeyApiTypeScriptPlugin['Instance']; - state: PluginState; }) => { - operationToDataType({ operation, plugin, state }); - - const f = plugin.gen.ensureFile(plugin.output); + operationToDataType({ operation, plugin }); const { error, errors, response, responses } = operationResponsesMap(operation); if (errors) { - const symbolErrors = f.addSymbol({ + const symbolErrors = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.errors, name: operation.id, @@ -168,20 +167,22 @@ export const operationToType = ({ selector: plugin.api.getSelector('errors', operation.id), }); const type = schemaToType({ - onRef: undefined, plugin, schema: errors, - state, }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolErrors.exported, name: symbolErrors.placeholder, type, }); - symbolErrors.update({ value: node }); + plugin.setSymbolValue(symbolErrors, node); if (error) { - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: { case: plugin.config.errors.case, @@ -201,16 +202,20 @@ export const operationToType = ({ }), }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbol.exported, name: symbol.placeholder, type, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, node); } } if (responses) { - const symbolResponses = f.addSymbol({ + const symbolResponses = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.responses, name: operation.id, @@ -218,20 +223,22 @@ export const operationToType = ({ selector: plugin.api.getSelector('responses', operation.id), }); const type = schemaToType({ - onRef: undefined, plugin, schema: responses, - state, }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolResponses.exported, name: symbolResponses.placeholder, type, }); - symbolResponses.update({ value: node }); + plugin.setSymbolValue(symbolResponses, node); if (response) { - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: { case: plugin.config.responses.case, @@ -253,11 +260,11 @@ export const operationToType = ({ }), }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbol.exported, name: symbol.placeholder, type, }); - symbol.update({ value: node }); + plugin.setSymbolValue(symbol, 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 256924466..008d945e2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/plugin.ts @@ -1,10 +1,7 @@ -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'; import { buildName } from '../../../openApi/shared/utils/name'; import type { Property } from '../../../tsc'; import { tsc } from '../../../tsc'; @@ -15,27 +12,21 @@ import { createSchemaComment } from '../../shared/utils/schema'; import { createClientOptions } from './clientOptions'; import { exportType } from './export'; import { operationToType } from './operation'; -import type { HeyApiTypeScriptPlugin, PluginState } from './types'; +import type { HeyApiTypeScriptPlugin } from './types'; import { webhookToType } from './webhook'; import { createWebhooks } from './webhooks'; -export type OnRef = (symbol: ICodegenSymbolOut) => void; - interface SchemaWithType['type']> extends Omit { type: Extract['type'], T>; } const arrayTypeToIdentifier = ({ - onRef, plugin, schema, - state, }: { - onRef: OnRef | undefined; plugin: HeyApiTypeScriptPlugin['Instance']; schema: SchemaWithType<'array'>; - state: PluginState; }): ts.TypeNode => { if (!schema.items) { return tsc.typeArrayNode( @@ -49,10 +40,8 @@ const arrayTypeToIdentifier = ({ for (const item of schema.items!) { const type = schemaToType({ - onRef, plugin, schema: item, - state, }); itemTypes.push(type); } @@ -85,24 +74,18 @@ const booleanTypeToIdentifier = ({ }; const enumTypeToIdentifier = ({ - onRef, plugin, schema, - state, }: { - onRef: OnRef | undefined; plugin: HeyApiTypeScriptPlugin['Instance']; schema: SchemaWithType<'enum'>; - state: PluginState; }): ts.TypeNode => { const type = schemaToType({ - onRef, plugin, schema: { ...schema, type: undefined, }, - state, }); return type; }; @@ -133,15 +116,11 @@ const numberTypeToIdentifier = ({ }; const objectTypeToIdentifier = ({ - onRef, plugin, schema, - state, }: { - onRef: OnRef | undefined; plugin: HeyApiTypeScriptPlugin['Instance']; schema: SchemaWithType<'object'>; - state: PluginState; }): ts.TypeNode => { // TODO: parser - handle constants let indexKey: ts.TypeReferenceNode | undefined; @@ -154,10 +133,8 @@ const objectTypeToIdentifier = ({ for (const name in schema.properties) { const property = schema.properties[name]!; const propertyType = schemaToType({ - onRef, plugin, schema: property, - state, }); const isRequired = required.includes(name); schemaProperties.push({ @@ -223,27 +200,21 @@ const objectTypeToIdentifier = ({ type: indexPropertyItems.length === 1 ? schemaToType({ - onRef, plugin, schema: indexPropertyItems[0]!, - state, }) : schemaToType({ - onRef, plugin, schema: { items: indexPropertyItems, logicalOperator: 'or' }, - state, }), }; if (schema.propertyNames?.$ref) { indexKey = schemaToType({ - onRef, plugin, schema: { $ref: schema.propertyNames.$ref, }, - state, }) as ts.TypeReferenceNode; } } @@ -259,11 +230,9 @@ const objectTypeToIdentifier = ({ const stringTypeToIdentifier = ({ plugin, schema, - state, }: { plugin: HeyApiTypeScriptPlugin['Instance']; schema: SchemaWithType<'string'>; - state: PluginState; }): ts.TypeNode => { if (schema.const !== undefined) { return tsc.literalTypeNode({ @@ -296,16 +265,70 @@ const stringTypeToIdentifier = ({ const parts = String(schema.example).split('_'); parts.pop(); // remove the ID part const type = parts.join('_'); - state.usedTypeIDs.add(type); - const typeName = ensureValidIdentifier( - stringCase({ - case: plugin.config.case, - value: type + '_id', - }), - ); - return tsc.typeReferenceNode({ - typeName, - }); + + const selector = plugin.api.getSelector('TypeID', type); + if (!plugin.getSymbol(selector)) { + const selectorTypeId = plugin.api.getSelector('TypeID'); + + if (!plugin.getSymbol(selectorTypeId)) { + const symbolTypeId = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: 'TypeID', + selector: selectorTypeId, + }); + const nodeTypeId = tsc.typeAliasDeclaration({ + exportType: symbolTypeId.exported, + name: symbolTypeId.placeholder, + type: tsc.templateLiteralType({ + value: [ + tsc.typeReferenceNode({ typeName: 'T' }), + '_', + tsc.keywordTypeNode({ keyword: 'string' }), + ], + }), + typeParameters: [ + tsc.typeParameterDeclaration({ + constraint: tsc.keywordTypeNode({ + keyword: 'string', + }), + name: 'T', + }), + ], + }); + plugin.setSymbolValue(symbolTypeId, nodeTypeId); + } + + const symbolTypeId = plugin.referenceSymbol(selectorTypeId); + const symbolTypeName = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: stringCase({ + case: plugin.config.case, + value: `${type}_id`, + }), + selector, + }); + const node = tsc.typeAliasDeclaration({ + exportType: symbolTypeName.exported, + name: symbolTypeName.placeholder, + type: tsc.typeReferenceNode({ + typeArguments: [ + tsc.literalTypeNode({ + literal: tsc.stringLiteral({ text: type }), + }), + ], + typeName: symbolTypeId.placeholder, + }), + }); + plugin.setSymbolValue(symbolTypeName, node); + } + const symbol = plugin.referenceSymbol(selector); + return tsc.typeReferenceNode({ typeName: symbol.placeholder }); } } @@ -315,15 +338,11 @@ const stringTypeToIdentifier = ({ }; const tupleTypeToIdentifier = ({ - onRef, plugin, schema, - state, }: { - onRef: OnRef | undefined; plugin: HeyApiTypeScriptPlugin['Instance']; schema: SchemaWithType<'tuple'>; - state: PluginState; }): ts.TypeNode => { let itemTypes: Array = []; @@ -335,10 +354,8 @@ const tupleTypeToIdentifier = ({ } else if (schema.items) { for (const item of schema.items) { const type = schemaToType({ - onRef, plugin, schema: item, - state, }); itemTypes.push(type); } @@ -350,21 +367,16 @@ const tupleTypeToIdentifier = ({ }; const schemaTypeToIdentifier = ({ - onRef, plugin, schema, - state, }: { - onRef: OnRef | undefined; plugin: HeyApiTypeScriptPlugin['Instance']; schema: IR.SchemaObject; - state: PluginState; }): ts.TypeNode => { const transformersPlugin = plugin.getPlugin('@hey-api/transformers'); if (transformersPlugin?.config.typeTransformers) { for (const typeTransformer of transformersPlugin.config.typeTransformers) { - const f = plugin.gen.ensureFile(plugin.output); - const typeNode = typeTransformer({ file: f, schema }); + const typeNode = typeTransformer({ schema }); if (typeNode) { return typeNode; } @@ -374,10 +386,8 @@ const schemaTypeToIdentifier = ({ switch (schema.type as Required['type']) { case 'array': return arrayTypeToIdentifier({ - onRef, plugin, schema: schema as SchemaWithType<'array'>, - state, }); case 'boolean': return booleanTypeToIdentifier({ @@ -385,10 +395,8 @@ const schemaTypeToIdentifier = ({ }); case 'enum': return enumTypeToIdentifier({ - onRef, plugin, schema: schema as SchemaWithType<'enum'>, - state, }); case 'integer': case 'number': @@ -406,23 +414,18 @@ const schemaTypeToIdentifier = ({ }); case 'object': return objectTypeToIdentifier({ - onRef, plugin, schema: schema as SchemaWithType<'object'>, - state, }); case 'string': return stringTypeToIdentifier({ plugin, schema: schema as SchemaWithType<'string'>, - state, }); case 'tuple': return tupleTypeToIdentifier({ - onRef, plugin, schema: schema as SchemaWithType<'tuple'>, - state, }); case 'undefined': return tsc.keywordTypeNode({ @@ -440,34 +443,21 @@ const schemaTypeToIdentifier = ({ }; export const schemaToType = ({ - onRef, plugin, schema, - state, }: { - /** - * Callback that can be used to perform side-effects when we encounter a - * reference. For example, we might want to import the referenced type. - */ - onRef: OnRef | undefined; plugin: HeyApiTypeScriptPlugin['Instance']; schema: IR.SchemaObject; - state: PluginState; }): ts.TypeNode => { - const f = plugin.gen.ensureFile(plugin.output); - if (schema.$ref) { - const symbol = f.ensureSymbol({ - selector: plugin.api.getSelector('ref', schema.$ref), - }); - if (onRef) { - onRef(symbol); - } + const symbol = plugin.referenceSymbol( + plugin.api.getSelector('ref', schema.$ref), + ); return tsc.typeReferenceNode({ typeName: symbol.placeholder }); } if (schema.type) { - return schemaTypeToIdentifier({ onRef, plugin, schema, state }); + return schemaTypeToIdentifier({ plugin, schema }); } if (schema.items) { @@ -476,7 +466,7 @@ export const schemaToType = ({ const itemTypes: Array = []; for (const item of schema.items) { - const type = schemaToType({ onRef, plugin, schema: item, state }); + const type = schemaToType({ plugin, schema: item }); itemTypes.push(type); } @@ -485,17 +475,15 @@ export const schemaToType = ({ : tsc.typeUnionNode({ types: itemTypes }); } - return schemaToType({ onRef, plugin, schema, state }); + return schemaToType({ plugin, schema }); } // catch-all fallback for failed schemas return schemaTypeToIdentifier({ - onRef, plugin, schema: { type: 'unknown', }, - state, }); }; @@ -503,23 +491,23 @@ const handleComponent = ({ id, plugin, schema, - state, }: { id: string; plugin: HeyApiTypeScriptPlugin['Instance']; schema: IR.SchemaObject; - state: PluginState; }) => { - const type = schemaToType({ onRef: undefined, plugin, schema, state }); - 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), - }), - }); + const type = schemaToType({ plugin, schema }); + const symbol = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: buildName({ + config: plugin.config.definitions, + name: refToName(id), + }), + selector: plugin.api.getSelector('ref', id), + }); exportType({ plugin, schema, @@ -529,14 +517,12 @@ const handleComponent = ({ }; export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - // reserve identifier for ClientOptions - const symbolClientOptions = f.addSymbol({ + const symbolClientOptions = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: { case: plugin.config.case, @@ -546,7 +532,11 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { selector: plugin.api.getSelector('ClientOptions'), }); // reserve identifier for Webhooks - const symbolWebhooks = f.addSymbol({ + const symbolWebhooks = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: { case: plugin.config.case, @@ -557,9 +547,6 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { }); const servers: Array = []; - const state: PluginState = { - usedTypeIDs: new Set(), - }; const webhookNames: Array = []; plugin.forEach( @@ -572,14 +559,13 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { (event) => { switch (event.type) { case 'operation': - operationToType({ operation: event.operation, plugin, state }); + operationToType({ operation: event.operation, plugin }); break; case 'parameter': handleComponent({ id: event.$ref, plugin, schema: event.parameter.schema, - state, }); break; case 'requestBody': @@ -587,7 +573,6 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { id: event.$ref, plugin, schema: event.requestBody.schema, - state, }); break; case 'schema': @@ -595,7 +580,6 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { id: event.$ref, plugin, schema: event.schema, - state, }); break; case 'server': @@ -606,7 +590,6 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { webhookToType({ operation: event.operation, plugin, - state, }), ); break; @@ -614,58 +597,6 @@ export const handler: HeyApiTypeScriptPlugin['Handler'] = ({ plugin }) => { }, ); - if (state.usedTypeIDs.size) { - const typeParameter = tsc.typeParameterDeclaration({ - constraint: tsc.keywordTypeNode({ - keyword: 'string', - }), - name: 'T', - }); - const symbolTypeId = f.addSymbol({ name: 'TypeID' }); - const node = tsc.typeAliasDeclaration({ - exportType: true, - name: symbolTypeId.placeholder, - type: tsc.templateLiteralType({ - value: [ - tsc.typeReferenceNode({ typeName: 'T' }), - '_', - tsc.keywordTypeNode({ keyword: 'string' }), - ], - }), - typeParameters: [typeParameter], - }); - symbolTypeId.update({ value: node }); - - for (const name of state.usedTypeIDs.values()) { - const symbolTypeName = f.addSymbol({ - name: ensureValidIdentifier( - stringCase({ - case: plugin.config.case, - value: `${name}_id`, - }), - ), - }); - const node = tsc.typeAliasDeclaration({ - exportType: true, - name: symbolTypeName.placeholder, - type: tsc.typeReferenceNode({ - typeArguments: [ - tsc.literalTypeNode({ - literal: tsc.stringLiteral({ text: name }), - }), - ], - typeName: symbolTypeId.placeholder, - }), - }); - symbolTypeName.update({ value: node }); - } - } - 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 }); - } + createWebhooks({ plugin, symbolWebhooks, webhookNames }); }; 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 d376378f2..5722a2fe5 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 @@ -4,509 +4,495 @@ import type { IApi } from './api'; export type EnumsType = 'javascript' | 'typescript' | 'typescript-const'; -export type UserConfig = Plugin.Name<'@hey-api/typescript'> & { - /** - * The casing convention to use for generated names. - * - * @default 'PascalCase' - */ - case?: Exclude; - /** - * Configuration for reusable schema definitions. - * - * Controls generation of shared types that can be referenced across - * requests and responses. - * - * Can be: - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default '{{name}}' - */ - definitions?: - | StringName - | { - /** - * The casing convention to use for generated definition names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Custom naming pattern for generated definition names. The name variable - * is obtained from the schema name. - * - * @default '{{name}}' - */ - name?: StringName; - }; - /** - * By default, enums are emitted as types to preserve runtime-free output. - * - * However, you may want to generate enums as JavaScript objects or - * TypeScript enums for runtime usage, interoperability, or integration with - * other tools. - * - * @default false - */ - enums?: - | boolean - | EnumsType - | { - /** - * The casing convention to use for generated names. - * - * @default 'SCREAMING_SNAKE_CASE' - */ - case?: StringCase; - /** - * When generating enums as JavaScript objects, they'll contain a null - * value if they're nullable. This might be undesirable if you want to do - * `Object.values(Foo)` and have all values be of the same type. - * - * This setting is disabled by default to preserve the source schemas. - * - * @default false - */ - constantsIgnoreNull?: boolean; - /** - * Whether to generate runtime enums. - * - * @default true - */ - enabled?: boolean; - /** - * Specifies the output mode for generated enums. - * - * Can be: - * - `javascript`: Generates JavaScript objects - * - `typescript`: Generates TypeScript enums - * - `typescript-const`: Generates TypeScript const enums - * - * @default 'javascript' - */ - mode?: EnumsType; - }; - /** - * Configuration for error-specific types. - * - * Controls generation of types for error response bodies and status codes. - * - * Can be: - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default '{{name}}Errors' - */ - errors?: - | StringName - | { - /** - * The casing convention to use for generated error type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Custom naming pattern for generated error type names. The name - * variable is obtained from the operation name. - * - * @default '{{name}}Error' - */ - error?: StringName; - /** - * Custom naming pattern for generated error type names. The name - * variable is obtained from the operation name. - * - * @default '{{name}}Errors' - */ - name?: StringName; - }; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default true - */ - exportFromIndex?: boolean; - /** - * Name of the generated file. - * - * @default 'types' - */ - output?: string; - /** - * Configuration for request-specific types. - * - * Controls generation of types for request bodies, query parameters, path - * parameters, and headers. - * - * Can be: - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default '{{name}}Data' - */ - requests?: - | StringName - | { - /** - * The casing convention to use for generated request type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Custom naming pattern for generated request type names. The name - * variable is obtained from the operation name. - * - * @default '{{name}}Data' - */ - name?: StringName; - }; - /** - * Configuration for response-specific types. - * - * Controls generation of types for response bodies and status codes. - * - * Can be: - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default '{{name}}Responses' - */ - responses?: - | StringName - | { - /** - * The casing convention to use for generated response type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Custom naming pattern for generated response type names. The name - * variable is obtained from the operation name. - * - * @default '{{name}}Responses' - */ - name?: StringName; - /** - * Custom naming pattern for generated response type names. The name - * variable is obtained from the operation name. - * - * @default '{{name}}Response' - */ - response?: StringName; - }; - /** - * The top type to use for untyped or unspecified schema values. - * - * Can be: - * - `unknown` (default): safe top type, you must narrow before use - * - `any`: disables type checking, can be used anywhere - * - * @default 'unknown' - */ - topType?: 'any' | 'unknown'; - /** - * Configuration for webhook-specific types. - * - * Controls generation of types for webhook payloads and webhook requests. - * - * Can be: - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default '{{name}}WebhookRequest' - */ - webhooks?: - | StringName - | { - /** - * The casing convention to use for generated webhook type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Custom naming pattern for generated webhook type names. The name - * variable is obtained from the webhook key. - * - * @default '{{name}}WebhookRequest' - */ - name?: StringName; - /** - * Custom naming pattern for generated webhook type names. The name - * variable is obtained from the webhook key. - * - * @default '{{name}}WebhookPayload' - */ - payload?: StringName; - }; - - // DEPRECATED OPTIONS BELOW - - /** - * **This feature works only with the legacy parser** - * - * Include only types matching regular expression. - * - * @deprecated - */ - // eslint-disable-next-line typescript-sort-keys/interface - include?: string; - /** - * **This feature works only with the legacy parser** - * - * Use your preferred naming pattern - * - * @deprecated - * @default 'preserve' - */ - style?: 'PascalCase' | 'preserve'; - /** - * **This feature works only with the legacy parser** - * - * Generate a tree of types containing all operations? It will be named - * $OpenApiTs. - * - * @deprecated - * @default false - */ - tree?: boolean; -}; - -export type Config = Plugin.Name<'@hey-api/typescript'> & { - /** - * The casing convention to use for generated names. - * - * @default 'PascalCase' - */ - case: Exclude; - /** - * Configuration for reusable schema definitions. - * - * Controls generation of shared types that can be referenced across - * requests and responses. - */ - definitions: { +export type UserConfig = Plugin.Name<'@hey-api/typescript'> & + Plugin.Hooks & { /** - * The casing convention to use for generated definition names. + * The casing convention to use for generated names. * * @default 'PascalCase' */ - case: StringCase; + case?: Exclude; /** - * Custom naming pattern for generated definition names. The name variable - * is obtained from the schema name. + * Configuration for reusable schema definitions. + * + * Controls generation of shared types that can be referenced across + * requests and responses. + * + * Can be: + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object * * @default '{{name}}' */ - name: StringName; - }; - /** - * By default, enums are emitted as types to preserve runtime-free output. - * - * However, you may want to generate enums as JavaScript objects or - * TypeScript enums for runtime usage, interoperability, or integration with - * other tools. - */ - enums: { + definitions?: + | StringName + | { + /** + * The casing convention to use for generated definition names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Custom naming pattern for generated definition names. The name variable + * is obtained from the schema name. + * + * @default '{{name}}' + */ + name?: StringName; + }; /** - * The casing convention to use for generated names. + * By default, enums are emitted as types to preserve runtime-free output. + * + * However, you may want to generate enums as JavaScript objects or + * TypeScript enums for runtime usage, interoperability, or integration with + * other tools. * - * @default 'SCREAMING_SNAKE_CASE' + * @default false */ - case: StringCase; + enums?: + | boolean + | EnumsType + | { + /** + * The casing convention to use for generated names. + * + * @default 'SCREAMING_SNAKE_CASE' + */ + case?: StringCase; + /** + * When generating enums as JavaScript objects, they'll contain a null + * value if they're nullable. This might be undesirable if you want to do + * `Object.values(Foo)` and have all values be of the same type. + * + * This setting is disabled by default to preserve the source schemas. + * + * @default false + */ + constantsIgnoreNull?: boolean; + /** + * Whether to generate runtime enums. + * + * @default true + */ + enabled?: boolean; + /** + * Specifies the output mode for generated enums. + * + * Can be: + * - `javascript`: Generates JavaScript objects + * - `typescript`: Generates TypeScript enums + * - `typescript-const`: Generates TypeScript const enums + * + * @default 'javascript' + */ + mode?: EnumsType; + }; /** - * When generating enums as JavaScript objects, they'll contain a null - * value if they're nullable. This might be undesirable if you want to do - * `Object.values(Foo)` and have all values be of the same type. + * Configuration for error-specific types. * - * This setting is disabled by default to preserve the source schemas. + * Controls generation of types for error response bodies and status codes. * - * @default false + * Can be: + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default '{{name}}Errors' */ - constantsIgnoreNull: boolean; + errors?: + | StringName + | { + /** + * The casing convention to use for generated error type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Custom naming pattern for generated error type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Error' + */ + error?: StringName; + /** + * Custom naming pattern for generated error type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Errors' + */ + name?: StringName; + }; /** - * Whether to generate runtime enums. + * Should the exports from the generated files be re-exported in the index + * barrel file? * - * @default false + * @default true */ - enabled: boolean; + exportFromIndex?: boolean; /** - * Specifies the output mode for generated enums. + * Configuration for request-specific types. + * + * Controls generation of types for request bodies, query parameters, path + * parameters, and headers. * * Can be: - * - `javascript`: Generates JavaScript objects - * - `typescript`: Generates TypeScript enums - * - `typescript-const`: Generates TypeScript const enums + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object * - * @default 'javascript' + * @default '{{name}}Data' */ - mode: EnumsType; - }; - /** - * Configuration for error-specific types. - * - * Controls generation of types for error response bodies and status codes. - * - * Can be: - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - */ - errors: { + requests?: + | StringName + | { + /** + * The casing convention to use for generated request type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Custom naming pattern for generated request type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Data' + */ + name?: StringName; + }; /** - * The casing convention to use for generated error type names. + * Configuration for response-specific types. * - * @default 'PascalCase' + * Controls generation of types for response bodies and status codes. + * + * Can be: + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default '{{name}}Responses' */ - case: StringCase; + responses?: + | StringName + | { + /** + * The casing convention to use for generated response type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Custom naming pattern for generated response type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Responses' + */ + name?: StringName; + /** + * Custom naming pattern for generated response type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Response' + */ + response?: StringName; + }; /** - * Custom naming pattern for generated error type names. The name - * variable is obtained from the operation name. + * The top type to use for untyped or unspecified schema values. * - * @default '{{name}}Error' + * Can be: + * - `unknown` (default): safe top type, you must narrow before use + * - `any`: disables type checking, can be used anywhere + * + * @default 'unknown' */ - error: StringName; + topType?: 'any' | 'unknown'; /** - * Custom naming pattern for generated error type names. The name - * variable is obtained from the operation name. + * Configuration for webhook-specific types. * - * @default '{{name}}Errors' + * Controls generation of types for webhook payloads and webhook requests. + * + * Can be: + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default '{{name}}WebhookRequest' */ - name: StringName; - }; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default true - */ - exportFromIndex: boolean; - /** - * Name of the generated file. - * - * @default 'types' - */ - output: string; - /** - * Configuration for request-specific types. - * - * Controls generation of types for request bodies, query parameters, path - * parameters, and headers. - */ - requests: { + webhooks?: + | StringName + | { + /** + * The casing convention to use for generated webhook type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Custom naming pattern for generated webhook type names. The name + * variable is obtained from the webhook key. + * + * @default '{{name}}WebhookRequest' + */ + name?: StringName; + /** + * Custom naming pattern for generated webhook type names. The name + * variable is obtained from the webhook key. + * + * @default '{{name}}WebhookPayload' + */ + payload?: StringName; + }; + + // DEPRECATED OPTIONS BELOW + /** - * The casing convention to use for generated request type names. + * **This feature works only with the legacy parser** * - * @default 'PascalCase' + * Include only types matching regular expression. + * + * @deprecated */ - case: StringCase; + // eslint-disable-next-line typescript-sort-keys/interface + include?: string; /** - * Custom naming pattern for generated request type names. The name - * variable is obtained from the operation name. + * **This feature works only with the legacy parser** * - * @default '{{name}}Data' + * Use your preferred naming pattern + * + * @deprecated + * @default 'preserve' */ - name: StringName; + style?: 'PascalCase' | 'preserve'; + /** + * **This feature works only with the legacy parser** + * + * Generate a tree of types containing all operations? It will be named + * $OpenApiTs. + * + * @deprecated + * @default false + */ + tree?: boolean; }; - /** - * Configuration for response-specific types. - * - * Controls generation of types for response bodies and status codes. - */ - responses: { + +export type Config = Plugin.Name<'@hey-api/typescript'> & + Plugin.Hooks & { /** - * The casing convention to use for generated response type names. + * The casing convention to use for generated names. * * @default 'PascalCase' */ - case: StringCase; + case: Exclude; /** - * Custom naming pattern for generated response type names. The name - * variable is obtained from the operation name. + * Configuration for reusable schema definitions. * - * @default '{{name}}Responses' + * Controls generation of shared types that can be referenced across + * requests and responses. */ - name: StringName; + definitions: { + /** + * The casing convention to use for generated definition names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Custom naming pattern for generated definition names. The name variable + * is obtained from the schema name. + * + * @default '{{name}}' + */ + name: StringName; + }; /** - * Custom naming pattern for generated response type names. The name - * variable is obtained from the operation name. + * By default, enums are emitted as types to preserve runtime-free output. * - * @default '{{name}}Response' + * However, you may want to generate enums as JavaScript objects or + * TypeScript enums for runtime usage, interoperability, or integration with + * other tools. */ - response: StringName; - }; - /** - * The top type to use for untyped or unspecified schema values. - * - * @default 'unknown' - */ - topType: 'any' | 'unknown'; - /** - * Configuration for webhook-specific types. - * - * Controls generation of types for webhook payloads and webhook requests. - */ - webhooks: { + enums: { + /** + * The casing convention to use for generated names. + * + * @default 'SCREAMING_SNAKE_CASE' + */ + case: StringCase; + /** + * When generating enums as JavaScript objects, they'll contain a null + * value if they're nullable. This might be undesirable if you want to do + * `Object.values(Foo)` and have all values be of the same type. + * + * This setting is disabled by default to preserve the source schemas. + * + * @default false + */ + constantsIgnoreNull: boolean; + /** + * Whether to generate runtime enums. + * + * @default false + */ + enabled: boolean; + /** + * Specifies the output mode for generated enums. + * + * Can be: + * - `javascript`: Generates JavaScript objects + * - `typescript`: Generates TypeScript enums + * - `typescript-const`: Generates TypeScript const enums + * + * @default 'javascript' + */ + mode: EnumsType; + }; /** - * The casing convention to use for generated webhook type names. + * Configuration for error-specific types. * - * @default 'PascalCase' + * Controls generation of types for error response bodies and status codes. + * + * Can be: + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object */ - case: StringCase; + errors: { + /** + * The casing convention to use for generated error type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Custom naming pattern for generated error type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Error' + */ + error: StringName; + /** + * Custom naming pattern for generated error type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Errors' + */ + name: StringName; + }; /** - * Custom naming pattern for generated webhook type names. The name - * variable is obtained from the webhook key. + * Should the exports from the generated files be re-exported in the index + * barrel file? * - * @default '{{name}}WebhookRequest' + * @default true */ - name: StringName; + exportFromIndex: boolean; /** - * Custom naming pattern for generated webhook type names. The name - * variable is obtained from the webhook key. + * Configuration for request-specific types. * - * @default '{{name}}WebhookPayload' + * Controls generation of types for request bodies, query parameters, path + * parameters, and headers. */ - payload: StringName; - }; - - // DEPRECATED OPTIONS BELOW + requests: { + /** + * The casing convention to use for generated request type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Custom naming pattern for generated request type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Data' + */ + name: StringName; + }; + /** + * Configuration for response-specific types. + * + * Controls generation of types for response bodies and status codes. + */ + responses: { + /** + * The casing convention to use for generated response type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Custom naming pattern for generated response type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Responses' + */ + name: StringName; + /** + * Custom naming pattern for generated response type names. The name + * variable is obtained from the operation name. + * + * @default '{{name}}Response' + */ + response: StringName; + }; + /** + * The top type to use for untyped or unspecified schema values. + * + * @default 'unknown' + */ + topType: 'any' | 'unknown'; + /** + * Configuration for webhook-specific types. + * + * Controls generation of types for webhook payloads and webhook requests. + */ + webhooks: { + /** + * The casing convention to use for generated webhook type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Custom naming pattern for generated webhook type names. The name + * variable is obtained from the webhook key. + * + * @default '{{name}}WebhookRequest' + */ + name: StringName; + /** + * Custom naming pattern for generated webhook type names. The name + * variable is obtained from the webhook key. + * + * @default '{{name}}WebhookPayload' + */ + payload: StringName; + }; - /** - * **This feature works only with the legacy parser** - * - * Include only types matching regular expression. - * - * @deprecated - */ - // eslint-disable-next-line typescript-sort-keys/interface - include?: string; - /** - * **This feature works only with the legacy parser** - * - * Use your preferred naming pattern - * - * @deprecated - * @default 'preserve' - */ - style: 'PascalCase' | 'preserve'; - /** - * **This feature works only with the legacy parser** - * - * Generate a tree of types containing all operations? It will be named - * $OpenApiTs. - * - * @deprecated - * @default false - */ - tree: boolean; -}; + // DEPRECATED OPTIONS BELOW -export interface PluginState { - usedTypeIDs: Set; -} + /** + * **This feature works only with the legacy parser** + * + * Include only types matching regular expression. + * + * @deprecated + */ + // eslint-disable-next-line typescript-sort-keys/interface + include?: string; + /** + * **This feature works only with the legacy parser** + * + * Use your preferred naming pattern + * + * @deprecated + * @default 'preserve' + */ + style: 'PascalCase' | 'preserve'; + /** + * **This feature works only with the legacy parser** + * + * Generate a tree of types containing all operations? It will be named + * $OpenApiTs. + * + * @deprecated + * @default false + */ + tree: boolean; + }; 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 fbdf1e24b..003f6238d 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/webhook.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/webhook.ts @@ -3,19 +3,15 @@ import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createSchemaComment } from '../../shared/utils/schema'; import { schemaToType } from './plugin'; -import type { HeyApiTypeScriptPlugin, PluginState } from './types'; +import type { HeyApiTypeScriptPlugin } from './types'; const operationToDataType = ({ operation, plugin, - state, }: { operation: IR.OperationObject; plugin: HeyApiTypeScriptPlugin['Instance']; - state: PluginState; }): string => { - const f = plugin.gen.ensureFile(plugin.output); - const data: IR.SchemaObject = { type: 'object', }; @@ -26,38 +22,40 @@ const operationToDataType = ({ } if (operation.body) { - 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 symbolWebhookPayload = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: buildName({ + config: { + case: plugin.config.webhooks.case, + name: plugin.config.webhooks.payload, + }, + name: operation.id, + }), + selector: plugin.api.getSelector('webhook-payload', operation.id), + }); const type = schemaToType({ - onRef: undefined, plugin, schema: operation.body.schema, - state, }); const node = tsc.typeAliasDeclaration({ comment: createSchemaComment({ schema: operation.body.schema }), - exportType: true, + exportType: symbolWebhookPayload.exported, name: symbolWebhookPayload.placeholder, type, }); - symbolWebhookPayload.update({ value: node }); + plugin.setSymbolValue(symbolWebhookPayload, node); - f.ensureSymbol({ - selector: plugin.api.getSelector('ref', symbolWebhookPayload.placeholder), - }).update({ + plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: symbolWebhookPayload.name, placeholder: symbolWebhookPayload.placeholder, + selector: plugin.api.getSelector('ref', symbolWebhookPayload.placeholder), }); data.properties.body = { $ref: symbolWebhookPayload.placeholder }; dataRequired.push('body'); @@ -76,7 +74,11 @@ const operationToDataType = ({ data.required = dataRequired; - const symbolWebhookRequest = f.addSymbol({ + const symbolWebhookRequest = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.webhooks, name: operation.id, @@ -84,17 +86,15 @@ const operationToDataType = ({ selector: plugin.api.getSelector('webhook-request', operation.id), }); const type = schemaToType({ - onRef: undefined, plugin, schema: data, - state, }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolWebhookRequest.exported, name: symbolWebhookRequest.placeholder, type, }); - symbolWebhookRequest.update({ value: node }); + plugin.setSymbolValue(symbolWebhookRequest, node); return symbolWebhookRequest.placeholder; }; @@ -102,13 +102,11 @@ const operationToDataType = ({ export const webhookToType = ({ operation, plugin, - state, }: { operation: IR.OperationObject; plugin: HeyApiTypeScriptPlugin['Instance']; - state: PluginState; }): string => { - const name = operationToDataType({ operation, plugin, state }); + const name = operationToDataType({ operation, plugin }); return name; // don't handle webhook responses for now, users only need requestBody 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 c39694fb6..4539a468e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/typescript/webhooks.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/typescript/webhooks.ts @@ -1,12 +1,15 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import { tsc } from '../../../tsc'; +import type { HeyApiTypeScriptPlugin } from './types'; export const createWebhooks = ({ + plugin, symbolWebhooks, webhookNames, }: { - symbolWebhooks: ICodegenSymbolOut; + plugin: HeyApiTypeScriptPlugin['Instance']; + symbolWebhooks: Symbol; webhookNames: ReadonlyArray; }) => { if (!webhookNames.length) return; @@ -17,9 +20,9 @@ export const createWebhooks = ({ ), }); const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolWebhooks.exported, name: symbolWebhooks.placeholder, type, }); - symbolWebhooks.update({ value: node }); + plugin.setSymbolValue(symbolWebhooks, node); }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/api.ts b/packages/openapi-ts/src/plugins/@pinia/colada/api.ts index 9af1e62ae..8b41d45a3 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/api.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -24,15 +24,13 @@ export type IApi = { * - `UseQueryOptions`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@pinia/colada'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/config.ts b/packages/openapi-ts/src/plugins/@pinia/colada/config.ts index 13b181d52..e420831ff 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/config.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/config.ts @@ -15,7 +15,6 @@ export const defaultConfig: PiniaColadaPlugin['Config'] = { dependencies: ['@hey-api/typescript', '@hey-api/sdk'], handler: handler as PiniaColadaPlugin['Handler'], name: '@pinia/colada', - output: '@pinia/colada', resolveConfig: (plugin, context) => { plugin.config.mutationOptions = context.valueToObject({ defaultValue: { diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts b/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts index 9abd00ca5..9e557afaa 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/mutationOptions.ts @@ -5,7 +5,6 @@ import { buildName } from '../../../openApi/shared/utils/name'; import { tsc } from '../../../tsc'; import { createOperationComment } from '../../shared/utils/operation'; import { handleMeta } from './meta'; -import type { PluginState } from './state'; import type { PiniaColadaPlugin } from './types'; import { useTypeData, useTypeError, useTypeResponse } from './useType'; import { getPublicTypeData } from './utils'; @@ -14,29 +13,14 @@ export const createMutationOptions = ({ operation, plugin, queryFn, - state, }: { operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; queryFn: string; - state: PluginState; }): void => { - const f = plugin.gen.ensureFile(plugin.output); - - if (!state.hasMutations) { - state.hasMutations = true; - } - - const symbolMutationOptionsType = f.ensureSymbol({ - name: 'UseMutationOptions', - selector: plugin.api.getSelector('UseMutationOptions'), - }); - f.addImport({ - from: plugin.name, - typeNames: [symbolMutationOptionsType.name], - }); - - state.hasUsedQueryFn = true; + const symbolMutationOptionsType = plugin.referenceSymbol( + plugin.api.getSelector('UseMutationOptions'), + ); const typeData = useTypeData({ operation, plugin }); const typeError = useTypeError({ operation, plugin }); @@ -124,7 +108,8 @@ export const createMutationOptions = ({ }); } - const symbolMutationOptions = f.addSymbol({ + const symbolMutationOptions = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.mutationOptions, name: operation.id, @@ -134,7 +119,7 @@ export const createMutationOptions = ({ comment: plugin.config.comments ? createOperationComment({ operation }) : undefined, - exportConst: true, + exportConst: symbolMutationOptions.exported, expression: tsc.arrowFunction({ parameters: [ { @@ -154,5 +139,5 @@ export const createMutationOptions = ({ }), name: symbolMutationOptions.placeholder, }); - symbolMutationOptions.update({ value: statement }); + plugin.setSymbolValue(symbolMutationOptions.id, statement); }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts b/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts index 46b7dc1d9..4de223285 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts @@ -1,43 +1,46 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; - -import { TypeScriptRenderer } from '../../../generate/renderer'; import { stringCase } from '../../../utils/stringCase'; -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'; export const handler: PiniaColadaPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), + plugin.registerSymbol({ + external: plugin.name, + meta: { + kind: 'type', + }, + name: 'UseMutationOptions', + selector: plugin.api.getSelector('UseMutationOptions'), + }); + plugin.registerSymbol({ + external: plugin.name, + meta: { + kind: 'type', + }, + name: 'UseQueryOptions', + selector: plugin.api.getSelector('UseQueryOptions'), + }); + plugin.registerSymbol({ + external: plugin.name, + meta: { + kind: 'type', + }, + name: '_JSONValue', + selector: plugin.api.getSelector('_JSONValue'), + }); + plugin.registerSymbol({ + external: 'axios', + meta: { + kind: 'type', + }, + name: 'AxiosError', + selector: plugin.api.getSelector('AxiosError'), }); - - 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 classes = sdkPlugin.config.asClass ? operationClasses({ context: plugin.context, @@ -49,84 +52,35 @@ export const handler: PiniaColadaPlugin['Handler'] = ({ plugin }) => { const queryFn = // TODO: this should use class graph to determine correct path string // as it's really easy to break once we change the class casing - ( - entry - ? [ - entry.path[0], - ...entry.path.slice(1).map((className: string) => - stringCase({ - case: 'camelCase', - value: className, - }), - ), - entry.methodName, - ].filter(Boolean) - : [ - serviceFunctionIdentifier({ - config: plugin.context.config, - handleIllegal: true, - id: operation.id, - operation, + entry + ? [ + plugin.referenceSymbol( + sdkPlugin.api.getSelector('class', entry.path[0]), + ).placeholder, + ...entry.path.slice(1).map((className: string) => + stringCase({ + case: 'camelCase', + value: className, }), - ] - ).join('.'); + ), + entry.methodName, + ] + .filter(Boolean) + .join('.') + : plugin.referenceSymbol( + sdkPlugin.api.getSelector('function', operation.id), + ).placeholder; if (plugin.hooks.operation.isQuery(operation)) { if (plugin.config.queryOptions.enabled) { - createQueryOptions({ - operation, - plugin, - queryFn, - state, - }); + createQueryOptions({ operation, plugin, queryFn }); } } if (plugin.hooks.operation.isMutation(operation)) { if (plugin.config.mutationOptions.enabled) { - createMutationOptions({ - operation, - plugin, - queryFn, - state, - }); - } - } - - if (state.hasUsedQueryFn) { - const symbolImport = plugin.gen.selectSymbolFirst( - entry - ? sdkPlugin.api.getSelector('class', entry.path[0]) - : sdkPlugin.api.getSelector('function', operation.id), - ); - if (symbolImport) { - f.addImport({ - from: symbolImport.file, - names: [symbolImport.placeholder], - }); + createMutationOptions({ operation, plugin, queryFn }); } } }); - - 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], - }); - } - } - } - - 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 073f2d5ec..690379161 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import type { Expression } from 'typescript'; import { hasOperationDataRequired } from '../../../ir/operation'; @@ -22,21 +22,18 @@ export const createQueryKeyFunction = ({ }: { plugin: PiniaColadaPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(plugin.output); - - 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 symbolCreateQueryKey = plugin.registerSymbol({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'createQueryKey', + }), + selector: plugin.api.getSelector('createQueryKey'), }); + const symbolQueryKeyType = plugin.referenceSymbol( + plugin.api.getSelector('QueryKey'), + ); const returnType = tsc.indexedAccessTypeNode({ indexType: tsc.literalTypeNode({ @@ -51,17 +48,17 @@ export const createQueryKeyFunction = ({ const baseUrlKey = getClientBaseUrlKey(plugin.context.config); const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( 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 symbolClient = + client.api && 'getSelector' in client.api + ? plugin.getSymbol( + // @ts-expect-error + client.api.getSelector('client'), + ) + : undefined; const fn = tsc.constVariable({ expression: tsc.arrowFunction({ @@ -249,7 +246,7 @@ export const createQueryKeyFunction = ({ }), name: symbolCreateQueryKey.placeholder, }); - symbolCreateQueryKey.update({ value: fn }); + plugin.setSymbolValue(symbolCreateQueryKey, fn); }; const createQueryKeyLiteral = ({ @@ -261,8 +258,6 @@ const createQueryKeyLiteral = ({ operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(plugin.output); - const config = plugin.config.queryKeys; let tagsExpression: Expression | undefined; if (config.tags && operation.tags && operation.tags.length > 0) { @@ -271,9 +266,9 @@ const createQueryKeyLiteral = ({ }); } - const symbolCreateQueryKey = f.ensureSymbol({ - selector: plugin.api.getSelector('createQueryKey'), - }); + const symbolCreateQueryKey = plugin.referenceSymbol( + plugin.api.getSelector('createQueryKey'), + ); const createQueryKeyCallExpression = tsc.callExpression({ functionName: symbolCreateQueryKey.placeholder, parameters: [tsc.ots.string(id), 'options', tagsExpression], @@ -286,15 +281,9 @@ export const createQueryKeyType = ({ }: { plugin: PiniaColadaPlugin['Instance']; }) => { - 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 symbolJsonValue = plugin.referenceSymbol( + plugin.api.getSelector('_JSONValue'), + ); const properties: Array = [ { @@ -324,14 +313,19 @@ export const createQueryKeyType = ({ ]; const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.getSelector('Options'), ); - const symbolQueryKeyType = f - .ensureSymbol({ selector: plugin.api.getSelector('QueryKey') }) - .update({ name: 'QueryKey' }); + const symbolQueryKeyType = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: 'QueryKey', + selector: plugin.api.getSelector('QueryKey'), + }); const queryKeyType = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolQueryKeyType.exported, name: symbolQueryKeyType.placeholder, type: tsc.typeTupleNode({ types: [ @@ -357,7 +351,7 @@ export const createQueryKeyType = ({ }, ], }); - symbolQueryKeyType.update({ value: queryKeyType }); + plugin.setSymbolValue(symbolQueryKeyType, queryKeyType); }; export const queryKeyStatement = ({ @@ -367,12 +361,12 @@ export const queryKeyStatement = ({ }: { operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; - symbol: ICodegenSymbolOut; + symbol: Symbol; }) => { const typeData = useTypeData({ operation, plugin }); const { strippedTypeData } = getPublicTypeData({ plugin, typeData }); const statement = tsc.constVariable({ - exportConst: true, + exportConst: symbol.exported, expression: tsc.arrowFunction({ parameters: [ { diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts b/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts index 05e82ebec..6449279b5 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts @@ -14,7 +14,6 @@ import { createQueryKeyType, queryKeyStatement, } from './queryKey'; -import type { PluginState } from './state'; import type { PiniaColadaPlugin } from './types'; import { useTypeData, useTypeError, useTypeResponse } from './useType'; import { getPublicTypeData } from './utils'; @@ -26,45 +25,31 @@ export const createQueryOptions = ({ operation, plugin, queryFn, - state, }: { operation: IR.OperationObject; plugin: PiniaColadaPlugin['Instance']; queryFn: string; - state: PluginState; }): void => { if (hasOperationSse({ operation })) { return; } - const f = plugin.gen.ensureFile(plugin.output); const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, }); - if (!state.hasQueries) { - state.hasQueries = true; - - if (!state.hasCreateQueryKeyParamsFunction) { - createQueryKeyType({ plugin }); - createQueryKeyFunction({ plugin }); - state.hasCreateQueryKeyParamsFunction = true; - } + if (!plugin.getSymbol(plugin.api.getSelector('createQueryKey'))) { + createQueryKeyType({ plugin }); + createQueryKeyFunction({ plugin }); } - const symbolUseQueryOptions = f.ensureSymbol({ - name: 'UseQueryOptions', - selector: plugin.api.getSelector('UseQueryOptions'), - }); - f.addImport({ - from: plugin.name, - typeNames: [symbolUseQueryOptions.name], - }); + const symbolUseQueryOptions = plugin.referenceSymbol( + plugin.api.getSelector('UseQueryOptions'), + ); - state.hasUsedQueryFn = true; - - const symbolQueryKey = f.addSymbol({ + const symbolQueryKey = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.queryKeys, name: operation.id, @@ -75,7 +60,7 @@ export const createQueryOptions = ({ plugin, symbol: symbolQueryKey, }); - symbolQueryKey.update({ value: node }); + plugin.setSymbolValue(symbolQueryKey, node); const typeData = useTypeData({ operation, plugin }); const typeError = useTypeError({ operation, plugin }); @@ -164,21 +149,19 @@ 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 symbolQueryOptionsFn = plugin.registerSymbol({ + exported: true, + name: buildName({ + config: plugin.config.queryOptions, + name: operation.id, + }), + selector: plugin.api.getSelector('queryOptionsFn', operation.id), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) : undefined, - exportConst: true, + exportConst: symbolQueryOptionsFn.exported, expression: tsc.arrowFunction({ parameters: [ { @@ -201,5 +184,5 @@ export const createQueryOptions = ({ }), name: symbolQueryOptionsFn.placeholder, }); - symbolQueryOptionsFn.update({ value: statement }); + plugin.setSymbolValue(symbolQueryOptionsFn, statement); }; diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/state.ts b/packages/openapi-ts/src/plugins/@pinia/colada/state.ts deleted file mode 100644 index cb952f3e6..000000000 --- a/packages/openapi-ts/src/plugins/@pinia/colada/state.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface PluginState { - hasCreateQueryKeyParamsFunction: boolean; - hasMutations: boolean; - hasQueries: boolean; - hasUsedQueryFn: boolean; -} 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 26ed75c91..a69bd0445 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/types.d.ts @@ -88,12 +88,6 @@ export type UserConfig = Plugin.Name<'@pinia/colada'> & */ name?: StringName; }; - /** - * Name of the generated file. - * - * @default '@pinia/colada' - */ - output?: string; /** * Configuration for generated query keys. * @@ -267,12 +261,6 @@ export type Config = Plugin.Name<'@pinia/colada'> & */ name: StringName; }; - /** - * Name of the generated file. - * - * @default '@pinia/colada' - */ - output: string; /** * Resolved configuration for generated query keys. * diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/useType.ts b/packages/openapi-ts/src/plugins/@pinia/colada/useType.ts index 82eac2291..245051b8a 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/useType.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/useType.ts @@ -10,13 +10,8 @@ export const useTypeData = ({ 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, - }); + const typeData = operationOptionsType({ operation, plugin: pluginSdk }); return typeData; }; @@ -27,32 +22,19 @@ export const useTypeError = ({ 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( + const symbolErrorType = plugin.getSymbol( 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], - }); + const symbol = plugin.referenceSymbol(plugin.api.getSelector('AxiosError')); typeErrorName = `${symbol.placeholder}<${typeErrorName}>`; } return typeErrorName; @@ -65,16 +47,9 @@ export const useTypeResponse = ({ 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( + const symbolResponseType = plugin.getSymbol( 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/angular-query-experimental/api.ts b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/api.ts index 357aff01d..9086df45f 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/api.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/angular-query-experimental/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -32,7 +32,7 @@ export type IApi = { * - `useQuery`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { @@ -40,9 +40,7 @@ export class Api implements IApi { public meta: Plugin.Name<'@tanstack/angular-query-experimental'>, ) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 96fe6a7ff..76d319b8f 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 @@ -190,12 +190,6 @@ export type UserConfig = Plugin.Name<'@tanstack/angular-query-experimental'> & */ name?: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/angular-query-experimental' - */ - output?: string; /** * Configuration for generated query keys. * @@ -459,12 +453,6 @@ export type Config = Plugin.Name<'@tanstack/angular-query-experimental'> & */ name: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/angular-query-experimental' - */ - output: string; /** * Resolved configuration for generated query keys. * 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 985a2f4c4..6b33b233a 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/infiniteQueryOptions.ts @@ -15,7 +15,7 @@ import { createQueryKeyType, queryKeyStatement, } from './queryKey'; -import type { PluginInstance, PluginState } from './types'; +import type { PluginInstance } from './types'; import { useTypeData, useTypeError, useTypeResponse } from './useType'; const createInfiniteParamsFunction = ({ @@ -23,18 +23,15 @@ const createInfiniteParamsFunction = ({ }: { plugin: PluginInstance; }) => { - const f = plugin.gen.ensureFile(plugin.output); - - const symbolCreateInfiniteParams = f - .ensureSymbol({ selector: plugin.api.getSelector('createInfiniteParams') }) - .update({ - name: buildName({ - config: { - case: plugin.config.case, - }, - name: 'createInfiniteParams', - }), - }); + const symbolCreateInfiniteParams = plugin.registerSymbol({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'createInfiniteParams', + }), + selector: plugin.api.getSelector('createInfiniteParams'), + }); const fn = tsc.constVariable({ expression: tsc.arrowFunction({ @@ -218,19 +215,17 @@ const createInfiniteParamsFunction = ({ }), name: symbolCreateInfiniteParams.placeholder, }); - symbolCreateInfiniteParams.update({ value: fn }); + plugin.setSymbolValue(symbolCreateInfiniteParams, fn); }; export const createInfiniteQueryOptions = ({ operation, plugin, queryFn, - state, }: { operation: IR.OperationObject; plugin: PluginInstance; queryFn: string; - state: PluginState; }): void => { const pagination = operationPagination({ context: plugin.context, @@ -241,67 +236,50 @@ export const createInfiniteQueryOptions = ({ return; } - const f = plugin.gen.ensureFile(plugin.output); const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, }); - if (!state.hasInfiniteQueries) { - state.hasInfiniteQueries = true; - - if (!state.hasCreateQueryKeyParamsFunction) { - createQueryKeyType({ plugin }); - createQueryKeyFunction({ plugin }); - state.hasCreateQueryKeyParamsFunction = true; - } - - if (!state.hasCreateInfiniteParamsFunction) { - createInfiniteParamsFunction({ plugin }); - state.hasCreateInfiniteParamsFunction = true; - } + if (!plugin.getSymbol(plugin.api.getSelector('createQueryKey'))) { + createQueryKeyType({ plugin }); + createQueryKeyFunction({ plugin }); } - 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], - }); + if (!plugin.getSymbol(plugin.api.getSelector('createInfiniteParams'))) { + createInfiniteParamsFunction({ plugin }); + } - state.hasUsedQueryFn = true; + const symbolInfiniteQueryOptions = plugin.referenceSymbol( + plugin.api.getSelector('infiniteQueryOptions'), + ); + const symbolInfiniteDataType = plugin.referenceSymbol( + plugin.api.getSelector('InfiniteData'), + ); const typeData = useTypeData({ operation, plugin }); const typeError = useTypeError({ operation, plugin }); const typeResponse = useTypeResponse({ operation, plugin }); - const symbolQueryKeyType = f.ensureSymbol({ - selector: plugin.api.getSelector('QueryKey'), - }); + const symbolQueryKeyType = plugin.referenceSymbol( + plugin.api.getSelector('QueryKey'), + ); const typeQueryKey = `${symbolQueryKeyType.placeholder}<${typeData}>`; const typePageObjectParam = `Pick<${typeQueryKey}[0], 'body' | 'headers' | 'path' | 'query'>`; 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 = { - usedTypeIDs: new Set(), - }; const type = pluginTypeScript.api.schemaToType({ plugin: pluginTypeScript, schema: pagination.schema, - state: typescriptState, }); const typePageParam = `${tsNodeToString({ node: type, unescape: true, })} | ${typePageObjectParam}`; - const symbolInfiniteQueryKey = f.addSymbol({ + const symbolInfiniteQueryKey = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.infiniteQueryKeys, name: operation.id, @@ -314,7 +292,7 @@ export const createInfiniteQueryOptions = ({ symbol: symbolInfiniteQueryKey, typeQueryKey, }); - symbolInfiniteQueryKey.update({ value: node }); + plugin.setSymbolValue(symbolInfiniteQueryKey, node); const awaitSdkExpression = tsc.awaitExpression({ expression: tsc.callExpression({ @@ -346,9 +324,9 @@ export const createInfiniteQueryOptions = ({ }), }); - const symbolCreateInfiniteParams = f.ensureSymbol({ - selector: plugin.api.getSelector('createInfiniteParams'), - }); + const symbolCreateInfiniteParams = plugin.referenceSymbol( + plugin.api.getSelector('createInfiniteParams'), + ); const statements: Array = [ tsc.constVariable({ @@ -463,7 +441,8 @@ export const createInfiniteQueryOptions = ({ }); } - const symbolInfiniteQueryOptionsFn = f.addSymbol({ + const symbolInfiniteQueryOptionsFn = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.infiniteQueryOptions, name: operation.id, @@ -473,7 +452,7 @@ export const createInfiniteQueryOptions = ({ comment: plugin.config.comments ? createOperationComment({ operation }) : undefined, - exportConst: true, + exportConst: symbolInfiniteQueryOptionsFn.exported, expression: tsc.arrowFunction({ parameters: [ { @@ -509,5 +488,5 @@ export const createInfiniteQueryOptions = ({ }), name: symbolInfiniteQueryOptionsFn.placeholder, }); - symbolInfiniteQueryOptionsFn.update({ value: statement }); + plugin.setSymbolValue(symbolInfiniteQueryOptionsFn, 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 02f2ea0e1..f415010a2 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/mutationOptions.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/mutationOptions.ts @@ -5,43 +5,21 @@ 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 type { PluginInstance } from './types'; import { useTypeData, useTypeError, useTypeResponse } from './useType'; export const createMutationOptions = ({ operation, plugin, queryFn, - state, }: { operation: IR.OperationObject; plugin: PluginInstance; queryFn: string; - state: PluginState; }): void => { - const mutationsType = - plugin.name === '@tanstack/angular-query-experimental' || - plugin.name === '@tanstack/svelte-query' || - plugin.name === '@tanstack/solid-query' - ? 'MutationOptions' - : 'UseMutationOptions'; - - const f = plugin.gen.ensureFile(plugin.output); - - if (!state.hasMutations) { - state.hasMutations = true; - } - - const symbolMutationOptionsType = f.ensureSymbol({ - name: mutationsType, - selector: plugin.api.getSelector('MutationOptions'), - }); - f.addImport({ - from: plugin.name, - typeNames: [symbolMutationOptionsType.name], - }); - - state.hasUsedQueryFn = true; + const symbolMutationOptionsType = plugin.referenceSymbol( + plugin.api.getSelector('MutationOptions'), + ); const typeData = useTypeData({ operation, plugin }); const typeError = useTypeError({ operation, plugin }); @@ -143,7 +121,8 @@ export const createMutationOptions = ({ }), ], }); - const symbolMutationOptions = f.addSymbol({ + const symbolMutationOptions = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.mutationOptions, name: operation.id, @@ -153,9 +132,9 @@ export const createMutationOptions = ({ comment: plugin.config.comments ? createOperationComment({ operation }) : undefined, - exportConst: true, + exportConst: symbolMutationOptions.exported, expression, name: symbolMutationOptions.placeholder, }); - symbolMutationOptions.update({ value: statement }); + plugin.setSymbolValue(symbolMutationOptions, statement); }; 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 8b0ce9a8e..73baee276 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts @@ -1,47 +1,69 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; - -import { TypeScriptRenderer } from '../../../generate/renderer'; import { stringCase } from '../../../utils/stringCase'; -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'; import { createMutationOptions } from './mutationOptions'; import { createQueryOptions } from './queryOptions'; -import type { PluginHandler, PluginState } from './types'; +import type { PluginHandler } from './types'; import { createUseQuery } from './useQuery'; export const handler: PluginHandler = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), + plugin.registerSymbol({ + external: plugin.name, + meta: { + kind: 'type', + }, + name: 'DefaultError', + selector: plugin.api.getSelector('DefaultError'), + }); + plugin.registerSymbol({ + external: plugin.name, + meta: { + kind: 'type', + }, + name: 'InfiniteData', + selector: plugin.api.getSelector('InfiniteData'), + }); + const mutationsType = + plugin.name === '@tanstack/angular-query-experimental' || + plugin.name === '@tanstack/svelte-query' || + plugin.name === '@tanstack/solid-query' + ? 'MutationOptions' + : 'UseMutationOptions'; + plugin.registerSymbol({ + external: plugin.name, + meta: { + kind: 'type', + }, + name: mutationsType, + selector: plugin.api.getSelector('MutationOptions'), + }); + plugin.registerSymbol({ + external: plugin.name, + name: 'infiniteQueryOptions', + selector: plugin.api.getSelector('infiniteQueryOptions'), + }); + plugin.registerSymbol({ + external: plugin.name, + name: 'queryOptions', + selector: plugin.api.getSelector('queryOptions'), + }); + plugin.registerSymbol({ + external: plugin.name, + name: 'useQuery', + selector: plugin.api.getSelector('useQuery'), + }); + plugin.registerSymbol({ + external: 'axios', + meta: { + kind: 'type', + }, + name: 'AxiosError', + selector: plugin.api.getSelector('AxiosError'), }); - - const state: PluginState = { - hasCreateInfiniteParamsFunction: false, - hasCreateQueryKeyParamsFunction: false, - hasInfiniteQueries: false, - hasMutations: false, - hasQueries: false, - hasUsedQueryFn: false, - typeInfiniteData: undefined!, - }; 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 classes = sdkPlugin.config.asClass ? operationClasses({ context: plugin.context, @@ -53,97 +75,43 @@ export const handler: PluginHandler = ({ plugin }) => { const queryFn = // TODO: this should use class graph to determine correct path string // as it's really easy to break once we change the class casing - ( - entry - ? [ - entry.path[0], - ...entry.path.slice(1).map((className) => - stringCase({ - case: 'camelCase', - value: className, - }), - ), - entry.methodName, - ].filter(Boolean) - : [ - serviceFunctionIdentifier({ - config: plugin.context.config, - handleIllegal: true, - id: operation.id, - operation, + entry + ? [ + plugin.referenceSymbol( + sdkPlugin.api.getSelector('class', entry.path[0]), + ).placeholder, + ...entry.path.slice(1).map((className) => + stringCase({ + case: 'camelCase', + value: className, }), - ] - ).join('.'); + ), + entry.methodName, + ] + .filter(Boolean) + .join('.') + : plugin.referenceSymbol( + sdkPlugin.api.getSelector('function', operation.id), + ).placeholder; if (plugin.hooks.operation.isQuery(operation)) { if (plugin.config.queryOptions.enabled) { - createQueryOptions({ - operation, - plugin, - queryFn, - state, - }); + createQueryOptions({ operation, plugin, queryFn }); } if (plugin.config.infiniteQueryOptions.enabled) { - createInfiniteQueryOptions({ - operation, - plugin, - queryFn, - state, - }); + createInfiniteQueryOptions({ operation, plugin, queryFn }); } if ('useQuery' in plugin.config && plugin.config.useQuery.enabled) { - createUseQuery({ operation, plugin, state }); + createUseQuery({ operation, plugin }); } } if (plugin.hooks.operation.isMutation(operation)) { if (plugin.config.mutationOptions.enabled) { - createMutationOptions({ - operation, - plugin, - queryFn, - state, - }); - } - } - - if (state.hasUsedQueryFn) { - const symbolImport = plugin.gen.selectSymbolFirst( - entry - ? sdkPlugin.api.getSelector('class', entry.path[0]) - : sdkPlugin.api.getSelector('function', operation.id), - ); - if (symbolImport) { - f.addImport({ - from: symbolImport.file, - names: [symbolImport.placeholder], - }); + createMutationOptions({ operation, plugin, queryFn }); } } }); - - if (state.hasQueries || state.hasInfiniteQueries) { - 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 329fd7fd1..08a80d370 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import type { Expression } from 'typescript'; import { hasOperationDataRequired } from '../../../ir/operation'; @@ -22,21 +22,18 @@ export const createQueryKeyFunction = ({ }: { plugin: PluginInstance; }) => { - const f = plugin.gen.ensureFile(plugin.output); - - 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 symbolCreateQueryKey = plugin.registerSymbol({ + name: buildName({ + config: { + case: plugin.config.case, + }, + name: 'createQueryKey', + }), + selector: plugin.api.getSelector('createQueryKey'), }); + const symbolQueryKeyType = plugin.referenceSymbol( + plugin.api.getSelector('QueryKey'), + ); const returnType = tsc.indexedAccessTypeNode({ indexType: tsc.literalTypeNode({ @@ -51,16 +48,16 @@ export const createQueryKeyFunction = ({ 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 symbolClient = + client.api && 'getSelector' in client.api + ? plugin.getSymbol( + // @ts-expect-error + client.api.getSelector('client'), + ) + : undefined; const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.getSelector('Options'), ); @@ -253,7 +250,7 @@ export const createQueryKeyFunction = ({ }), name: symbolCreateQueryKey.placeholder, }); - symbolCreateQueryKey.update({ value: fn }); + plugin.setSymbolValue(symbolCreateQueryKey, fn); }; const createQueryKeyLiteral = ({ @@ -267,8 +264,6 @@ const createQueryKeyLiteral = ({ operation: IR.OperationObject; plugin: PluginInstance; }) => { - const f = plugin.gen.ensureFile(plugin.output); - const config = isInfinite ? plugin.config.infiniteQueryKeys : plugin.config.queryKeys; @@ -279,9 +274,9 @@ const createQueryKeyLiteral = ({ }); } - const symbolCreateQueryKey = f.ensureSymbol({ - selector: plugin.api.getSelector('createQueryKey'), - }); + const symbolCreateQueryKey = plugin.referenceSymbol( + plugin.api.getSelector('createQueryKey'), + ); const createQueryKeyCallExpression = tsc.callExpression({ functionName: symbolCreateQueryKey.placeholder, parameters: [ @@ -297,8 +292,6 @@ const createQueryKeyLiteral = ({ }; export const createQueryKeyType = ({ plugin }: { plugin: PluginInstance }) => { - const f = plugin.gen.ensureFile(plugin.output); - const properties: Array = [ { name: '_id', @@ -317,14 +310,19 @@ export const createQueryKeyType = ({ plugin }: { plugin: PluginInstance }) => { ]; const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); - const symbolOptions = plugin.gen.selectSymbolFirstOrThrow( + const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.getSelector('Options'), ); - const symbolQueryKeyType = f - .ensureSymbol({ selector: plugin.api.getSelector('QueryKey') }) - .update({ name: 'QueryKey' }); + const symbolQueryKeyType = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: 'QueryKey', + selector: plugin.api.getSelector('QueryKey'), + }); const queryKeyType = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolQueryKeyType.exported, name: symbolQueryKeyType.placeholder, type: tsc.typeTupleNode({ types: [ @@ -350,7 +348,7 @@ export const createQueryKeyType = ({ plugin }: { plugin: PluginInstance }) => { }, ], }); - symbolQueryKeyType.update({ value: queryKeyType }); + plugin.setSymbolValue(symbolQueryKeyType, queryKeyType); }; export const queryKeyStatement = ({ @@ -363,12 +361,12 @@ export const queryKeyStatement = ({ isInfinite: boolean; operation: IR.OperationObject; plugin: PluginInstance; - symbol: ICodegenSymbolOut; + symbol: Symbol; typeQueryKey?: string; }) => { const typeData = useTypeData({ operation, plugin }); const statement = tsc.constVariable({ - exportConst: true, + exportConst: symbol.exported, expression: tsc.arrowFunction({ parameters: [ { 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 c32b7dc76..784d096cc 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryOptions.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryOptions.ts @@ -14,7 +14,7 @@ import { createQueryKeyType, queryKeyStatement, } from './queryKey'; -import type { PluginInstance, PluginState } from './types'; +import type { PluginInstance } from './types'; import { useTypeData } from './useType'; const optionsParamName = 'options'; @@ -23,45 +23,31 @@ export const createQueryOptions = ({ operation, plugin, queryFn, - state, }: { operation: IR.OperationObject; plugin: PluginInstance; queryFn: string; - state: PluginState; }): void => { if (hasOperationSse({ operation })) { return; } - const f = plugin.gen.ensureFile(plugin.output); const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, operation, }); - if (!state.hasQueries) { - state.hasQueries = true; - - if (!state.hasCreateQueryKeyParamsFunction) { - createQueryKeyType({ plugin }); - createQueryKeyFunction({ plugin }); - state.hasCreateQueryKeyParamsFunction = true; - } + if (!plugin.getSymbol(plugin.api.getSelector('createQueryKey'))) { + createQueryKeyType({ plugin }); + createQueryKeyFunction({ plugin }); } - const symbolQueryOptions = f.ensureSymbol({ - name: 'queryOptions', - selector: plugin.api.getSelector('queryOptions'), - }); - f.addImport({ - from: plugin.name, - names: [symbolQueryOptions.name], - }); + const symbolQueryOptions = plugin.referenceSymbol( + plugin.api.getSelector('queryOptions'), + ); - state.hasUsedQueryFn = true; - - const symbolQueryKey = f.addSymbol({ + const symbolQueryKey = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.queryKeys, name: operation.id, @@ -73,7 +59,7 @@ export const createQueryOptions = ({ plugin, symbol: symbolQueryKey, }); - symbolQueryKey.update({ value: node }); + plugin.setSymbolValue(symbolQueryKey, node); const typeData = useTypeData({ operation, plugin }); @@ -167,21 +153,19 @@ 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 symbolQueryOptionsFn = plugin.registerSymbol({ + exported: plugin.config.queryOptions.exported, + name: buildName({ + config: plugin.config.queryOptions, + name: operation.id, + }), + selector: plugin.api.getSelector('queryOptionsFn', operation.id), + }); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) : undefined, - exportConst: plugin.config.queryOptions.exported, + exportConst: symbolQueryOptionsFn.exported, expression: tsc.arrowFunction({ parameters: [ { @@ -201,5 +185,5 @@ export const createQueryOptions = ({ // TODO: add type error // TODO: AxiosError }); - symbolQueryOptionsFn.update({ value: statement }); + plugin.setSymbolValue(symbolQueryOptionsFn, 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 91fb26640..d765a8545 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 @@ -1,4 +1,3 @@ -import type { ImportExportItem } from '../../../tsc/module'; import type { TanStackAngularQueryPlugin } from '../angular-query-experimental/types'; import type { TanStackReactQueryPlugin } from '../react-query/types'; import type { TanStackSolidQueryPlugin } from '../solid-query/types'; @@ -19,14 +18,3 @@ export type PluginInstance = | TanStackSolidQueryPlugin['Instance'] | TanStackSvelteQueryPlugin['Instance'] | TanStackVueQueryPlugin['Instance']; - -export interface PluginState { - hasCreateInfiniteParamsFunction: boolean; - hasCreateQueryKeyParamsFunction: boolean; - hasInfiniteQueries: boolean; - hasMutations: boolean; - hasQueries: boolean; - hasUseQuery?: boolean; - hasUsedQueryFn: boolean; - typeInfiniteData: ImportExportItem; -} 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 fb3af4449..a77b1622c 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/useQuery.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/useQuery.ts @@ -6,7 +6,7 @@ import { hasOperationSse, isOperationOptionsRequired, } from '../../shared/utils/operation'; -import type { PluginInstance, PluginState } from './types'; +import type { PluginInstance } from './types'; import { useTypeData } from './useType'; const optionsParamName = 'options'; @@ -14,11 +14,9 @@ const optionsParamName = 'options'; export const createUseQuery = ({ operation, plugin, - state, }: { operation: IR.OperationObject; plugin: PluginInstance; - state: PluginState; }): void => { if (hasOperationSse({ operation })) { return; @@ -28,27 +26,17 @@ export const createUseQuery = ({ return; } - const f = plugin.gen.ensureFile(plugin.output); - - const symbolUseQueryFn = f.addSymbol({ + const symbolUseQueryFn = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.useQuery, name: operation.id, }), }); - if (!state.hasUseQuery) { - state.hasUseQuery = true; - } - - const symbolUseQuery = f.ensureSymbol({ - name: 'useQuery', - selector: plugin.api.getSelector('useQuery'), - }); - f.addImport({ - from: plugin.name, - names: [symbolUseQuery.name], - }); + const symbolUseQuery = plugin.referenceSymbol( + plugin.api.getSelector('useQuery'), + ); const isRequiredOptions = isOperationOptionsRequired({ context: plugin.context, @@ -56,14 +44,14 @@ export const createUseQuery = ({ }); const typeData = useTypeData({ operation, plugin }); - const symbolQueryOptionsFn = f.ensureSymbol({ - selector: plugin.api.getSelector('queryOptionsFn', operation.id), - }); + const symbolQueryOptionsFn = plugin.referenceSymbol( + plugin.api.getSelector('queryOptionsFn', operation.id), + ); const statement = tsc.constVariable({ comment: plugin.config.comments ? createOperationComment({ operation }) : undefined, - exportConst: true, + exportConst: symbolUseQueryFn.exported, expression: tsc.arrowFunction({ parameters: [ { @@ -88,5 +76,5 @@ export const createUseQuery = ({ }), name: symbolUseQueryFn.placeholder, }); - symbolUseQueryFn.update({ value: statement }); + plugin.setSymbolValue(symbolUseQueryFn, 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 12bb95829..41f0b6624 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/useType.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/useType.ts @@ -10,13 +10,8 @@ export const useTypeData = ({ operation: IR.OperationObject; plugin: PluginInstance; }): string => { - const f = plugin.gen.ensureFile(plugin.output); const pluginSdk = plugin.getPluginOrThrow('@hey-api/sdk'); - const typeData = operationOptionsType({ - file: f, - operation, - plugin: pluginSdk, - }); + const typeData = operationOptionsType({ operation, plugin: pluginSdk }); return typeData; }; @@ -27,39 +22,22 @@ export const useTypeError = ({ operation: IR.OperationObject; plugin: PluginInstance; }): 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( + const symbolErrorType = plugin.getSymbol( pluginTypeScript.api.getSelector('error', operation.id), ); - if (symbolErrorType) { - f.addImport({ - from: symbolErrorType.file, - typeNames: [symbolErrorType.placeholder], - }); - } 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], - }); + const symbol = plugin.referenceSymbol( + plugin.api.getSelector('DefaultError'), + ); typeErrorName = symbol.placeholder; } 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], - }); + const symbol = plugin.referenceSymbol(plugin.api.getSelector('AxiosError')); typeErrorName = `${symbol.placeholder}<${typeErrorName}>`; } return typeErrorName; @@ -72,16 +50,9 @@ export const useTypeResponse = ({ operation: IR.OperationObject; plugin: PluginInstance; }): string => { - const f = plugin.gen.ensureFile(plugin.output); const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolResponseType = plugin.gen.selectSymbolFirst( + const symbolResponseType = plugin.getSymbol( 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 index deb578eaa..33357cb95 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/react-query/api.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/react-query/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -32,15 +32,13 @@ export type IApi = { * - `useQuery`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@tanstack/react-query'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 85c5493d4..4a0de3251 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 @@ -196,12 +196,6 @@ export type UserConfig = Plugin.Name<'@tanstack/react-query'> & */ name?: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/react-query' - */ - output?: string; /** * Configuration for generated query keys. * @@ -508,12 +502,6 @@ export type Config = Plugin.Name<'@tanstack/react-query'> & */ name: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/react-query' - */ - output: string; /** * Resolved configuration for generated query keys. * diff --git a/packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts b/packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts index 4a7a1c027..b21c391db 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/solid-query/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -32,15 +32,13 @@ export type IApi = { * - `useQuery`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@tanstack/solid-query'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 9ac1e9467..2758857b1 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 @@ -191,12 +191,6 @@ export type UserConfig = Plugin.Name<'@tanstack/solid-query'> & */ name?: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/solid-query' - */ - output?: string; /** * Configuration for generated query keys. * @@ -460,12 +454,6 @@ export type Config = Plugin.Name<'@tanstack/solid-query'> & */ name: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/solid-query' - */ - output: string; /** * Resolved configuration for generated query keys. * diff --git a/packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts index 7cd44eb33..db6b292e6 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/svelte-query/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -32,15 +32,13 @@ export type IApi = { * - `useQuery`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@tanstack/svelte-query'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 9a343483c..2ff589aec 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 @@ -190,12 +190,6 @@ export type UserConfig = Plugin.Name<'@tanstack/svelte-query'> & */ name?: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/svelte-query' - */ - output?: string; /** * Configuration for generated query keys. * @@ -459,12 +453,6 @@ export type Config = Plugin.Name<'@tanstack/svelte-query'> & */ name: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/svelte-query' - */ - output: string; /** * Resolved configuration for generated query keys. * diff --git a/packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts b/packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts index ea1bf2080..72a6c77b0 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/vue-query/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../../types'; @@ -32,15 +32,13 @@ export type IApi = { * - `useQuery`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'@tanstack/vue-query'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } 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 accee34a2..99562511e 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 @@ -192,12 +192,6 @@ export type UserConfig = Plugin.Name<'@tanstack/vue-query'> & */ name?: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/vue-query' - */ - output?: string; /** * Configuration for generated query keys. * @@ -464,12 +458,6 @@ export type Config = Plugin.Name<'@tanstack/vue-query'> & */ name: StringName; }; - /** - * Name of the generated file. - * - * @default '@tanstack/vue-query' - */ - output: string; /** * Resolved configuration for generated query keys. * diff --git a/packages/openapi-ts/src/plugins/fastify/api.ts b/packages/openapi-ts/src/plugins/fastify/api.ts index 8ec88344e..b8b2cd8f7 100644 --- a/packages/openapi-ts/src/plugins/fastify/api.ts +++ b/packages/openapi-ts/src/plugins/fastify/api.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolSelector } from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type { Plugin } from '../types'; @@ -11,15 +11,13 @@ export type IApi = { * - `RouteHandler`: never * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'fastify'>) {} - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } diff --git a/packages/openapi-ts/src/plugins/fastify/config.ts b/packages/openapi-ts/src/plugins/fastify/config.ts index 31a440609..6db188294 100644 --- a/packages/openapi-ts/src/plugins/fastify/config.ts +++ b/packages/openapi-ts/src/plugins/fastify/config.ts @@ -13,7 +13,6 @@ export const defaultConfig: FastifyPlugin['Config'] = { dependencies: ['@hey-api/typescript'], handler, name: 'fastify', - output: 'fastify', }; /** diff --git a/packages/openapi-ts/src/plugins/fastify/plugin.ts b/packages/openapi-ts/src/plugins/fastify/plugin.ts index efa0ccaad..7c79bcbdc 100644 --- a/packages/openapi-ts/src/plugins/fastify/plugin.ts +++ b/packages/openapi-ts/src/plugins/fastify/plugin.ts @@ -1,6 +1,5 @@ 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'; @@ -14,20 +13,14 @@ const operationToRouteHandler = ({ operation: IR.OperationObject; plugin: FastifyPlugin['Instance']; }): Property | undefined => { - const f = plugin.gen.ensureFile(plugin.output); - const properties: Array = []; const pluginTypeScript = plugin.getPluginOrThrow('@hey-api/typescript'); - const symbolDataType = plugin.gen.selectSymbolFirst( + const symbolDataType = plugin.getSymbol( pluginTypeScript.api.getSelector('data', operation.id), ); if (symbolDataType) { if (operation.body) { - f.addImport({ - from: symbolDataType.file, - typeNames: [symbolDataType.placeholder], - }); properties.push({ isRequired: operation.body.required, name: 'Body', @@ -37,10 +30,6 @@ const operationToRouteHandler = ({ if (operation.parameters) { if (operation.parameters.header) { - f.addImport({ - from: symbolDataType.file, - typeNames: [symbolDataType.placeholder], - }); properties.push({ isRequired: hasParameterGroupObjectRequired( operation.parameters.header, @@ -51,10 +40,6 @@ const operationToRouteHandler = ({ } if (operation.parameters.path) { - f.addImport({ - from: symbolDataType.file, - typeNames: [symbolDataType.placeholder], - }); properties.push({ isRequired: hasParameterGroupObjectRequired( operation.parameters.path, @@ -65,10 +50,6 @@ const operationToRouteHandler = ({ } if (operation.parameters.query) { - f.addImport({ - from: symbolDataType.file, - typeNames: [symbolDataType.placeholder], - }); properties.push({ isRequired: hasParameterGroupObjectRequired( operation.parameters.query, @@ -83,7 +64,7 @@ const operationToRouteHandler = ({ const { errors, responses } = operationResponsesMap(operation); let errorsTypeReference: ts.TypeReferenceNode | undefined = undefined; - const symbolErrorType = plugin.gen.selectSymbolFirst( + const symbolErrorType = plugin.getSymbol( pluginTypeScript.api.getSelector('errors', operation.id), ); if (symbolErrorType && errors && errors.properties) { @@ -91,18 +72,10 @@ const operationToRouteHandler = ({ if (keys.length) { const hasDefaultResponse = keys.includes('default'); if (!hasDefaultResponse) { - f.addImport({ - from: symbolErrorType.file, - typeNames: [symbolErrorType.placeholder], - }); errorsTypeReference = tsc.typeReferenceNode({ typeName: symbolErrorType.placeholder, }); } else if (keys.length > 1) { - f.addImport({ - from: symbolErrorType.file, - typeNames: [symbolErrorType.placeholder], - }); const errorsType = tsc.typeReferenceNode({ typeName: symbolErrorType.placeholder, }); @@ -118,7 +91,7 @@ const operationToRouteHandler = ({ } let responsesTypeReference: ts.TypeReferenceNode | undefined = undefined; - const symbolResponseType = plugin.gen.selectSymbolFirst( + const symbolResponseType = plugin.getSymbol( pluginTypeScript.api.getSelector('responses', operation.id), ); if (symbolResponseType && responses && responses.properties) { @@ -126,18 +99,10 @@ const operationToRouteHandler = ({ if (keys.length) { const hasDefaultResponse = keys.includes('default'); if (!hasDefaultResponse) { - f.addImport({ - from: symbolResponseType.file, - typeNames: [symbolResponseType.placeholder], - }); responsesTypeReference = tsc.typeReferenceNode({ typeName: symbolResponseType.placeholder, }); } else if (keys.length > 1) { - f.addImport({ - from: symbolResponseType.file, - typeNames: [symbolResponseType.placeholder], - }); const responsesType = tsc.typeReferenceNode({ typeName: symbolResponseType.placeholder, }); @@ -168,9 +133,9 @@ const operationToRouteHandler = ({ return; } - const symbolRouteHandler = f.ensureSymbol({ - selector: plugin.api.getSelector('RouteHandler'), - }); + const symbolRouteHandler = plugin.referenceSymbol( + plugin.api.getSelector('RouteHandler'), + ); const routeHandler: Property = { name: operation.id, type: tsc.typeReferenceNode({ @@ -187,10 +152,21 @@ const operationToRouteHandler = ({ }; export const handler: FastifyPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), + plugin.registerSymbol({ + external: 'fastify', + meta: { + kind: 'type', + }, + name: 'RouteHandler', + selector: plugin.api.getSelector('RouteHandler'), + }); + + const symbolRouteHandlers = plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, + name: 'RouteHandlers', }); const routeHandlers: Array = []; @@ -202,25 +178,13 @@ export const handler: FastifyPlugin['Handler'] = ({ plugin }) => { } }); - const symbolRouteHandlers = f.addSymbol({ name: 'RouteHandlers' }); - - if (routeHandlers.length) { - const symbolRouteHandler = f - .ensureSymbol({ selector: plugin.api.getSelector('RouteHandler') }) - .update({ name: 'RouteHandler' }); - f.addImport({ - from: 'fastify', - typeNames: [symbolRouteHandler.name], - }); - } - const node = tsc.typeAliasDeclaration({ - exportType: true, + exportType: symbolRouteHandlers.exported, name: symbolRouteHandlers.placeholder, type: tsc.typeInterfaceNode({ properties: routeHandlers, useLegacyResolution: false, }), }); - symbolRouteHandlers.update({ value: node }); + plugin.setSymbolValue(symbolRouteHandlers, node); }; diff --git a/packages/openapi-ts/src/plugins/fastify/types.d.ts b/packages/openapi-ts/src/plugins/fastify/types.d.ts index ec050bcda..541c5c848 100644 --- a/packages/openapi-ts/src/plugins/fastify/types.d.ts +++ b/packages/openapi-ts/src/plugins/fastify/types.d.ts @@ -1,20 +1,15 @@ import type { DefinePlugin, Plugin } from '../types'; import type { IApi } from './api'; -export type UserConfig = Plugin.Name<'fastify'> & { - /** - * 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 'fastify' - */ - output?: string; -}; +export type UserConfig = Plugin.Name<'fastify'> & + Plugin.Hooks & { + /** + * Should the exports from the generated files be re-exported in the index + * barrel file? + * + * @default false + */ + exportFromIndex?: boolean; + }; 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 d4981a17b..332d7ea4c 100644 --- a/packages/openapi-ts/src/plugins/shared/utils/instance.ts +++ b/packages/openapi-ts/src/plugins/shared/utils/instance.ts @@ -1,4 +1,11 @@ -import type { CodegenProject } from '@hey-api/codegen-core'; +import path from 'node:path'; + +import type { + IProject, + Selector, + Symbol, + SymbolIn, +} from '@hey-api/codegen-core'; import { HeyApiError } from '../../../error'; import type { IR } from '../../../ir/types'; @@ -7,6 +14,22 @@ import type { PluginConfigMap } from '../../config'; import type { Plugin } from '../../types'; import type { WalkEvent, WalkEventType } from '../types/instance'; +const defaultGetFilePath = (symbol: Symbol): string | undefined => { + if (!symbol.meta?.pluginName) { + return; + } + if (symbol.meta.pluginName.startsWith('@hey-api/client-')) { + return 'client'; + } + if (symbol.meta.pluginName === '@hey-api/typescript') { + return 'types'; + } + if (symbol.meta.pluginName.startsWith('@hey-api/')) { + return symbol.meta.pluginName.split('/')[1]; + } + return symbol.meta.pluginName; +}; + const defaultGetKind: Required['operations']>['getKind'] = ( operation, ) => { @@ -19,7 +42,7 @@ const defaultGetKind: Required['operations']>['getKind'] = ( case 'get': return ['query']; default: - return []; + return; } }; @@ -28,10 +51,10 @@ export class PluginInstance { config: Omit; context: IR.Context; dependencies: Required>['dependencies'] = []; - gen: CodegenProject; + gen: IProject; private handler: Plugin.Config['handler']; name: T['resolvedConfig']['name']; - output: Required['output']; + output: string; /** * The package metadata and utilities for the current context, constructed * from the provided dependencies. Used for managing package-related @@ -47,7 +70,7 @@ export class PluginInstance { > & { api?: T['api']; context: IR.Context; - gen: CodegenProject; + gen: IProject; name: string; output: string; }, @@ -63,13 +86,6 @@ export class PluginInstance { this.package = props.context.package; } - createFile(file: IR.ContextFile) { - return this.context.createFile({ - exportFromIndex: this.config.exportFromIndex, - ...file, - }); - } - /** * Iterates over various input elements as specified by the event types, in * a specific order: servers, schemas, parameters, request bodies, then @@ -259,6 +275,33 @@ export class PluginInstance { return plugin as any; } + getSymbol(symbolIdOrSelector: number | Selector): Symbol | undefined { + return this.gen.symbols.get(symbolIdOrSelector); + } + + private getSymbolFilePath(symbol: Symbol): string | undefined { + const getFilePathFnPlugin = this.config['~hooks']?.symbols?.getFilePath; + const getFilePathFnPluginResult = getFilePathFnPlugin?.(symbol); + if (getFilePathFnPluginResult !== undefined) { + return getFilePathFnPluginResult; + } + const getFilePathFnParser = + this.context.config.parser.hooks.symbols?.getFilePath; + const getFilePathFnParserResult = getFilePathFnParser?.(symbol); + if (getFilePathFnParserResult !== undefined) { + return getFilePathFnParserResult; + } + return defaultGetFilePath(symbol); + } + + getSymbolValue(idOrSymbol: number | Symbol): unknown { + return this.gen.symbols.getValue(this.symbolToId(idOrSymbol)); + } + + hasSymbolValue(idOrSymbol: number | Symbol): boolean { + return this.gen.symbols.hasValue(this.symbolToId(idOrSymbol)); + } + hooks = { operation: { isMutation: (operation: IR.OperationObject): boolean => @@ -266,6 +309,10 @@ export class PluginInstance { isQuery: (operation: IR.OperationObject): boolean => this.isOperationKind(operation, 'query'), }, + symbol: { + getFilePath: (symbol: Symbol): string | undefined => + this.getSymbolFilePath(symbol), + }, }; private isOperationKind( @@ -295,7 +342,29 @@ export class PluginInstance { if (getKindFnParserResult !== undefined) { return getKindFnParserResult.includes(kind); } - return defaultGetKind(operation).includes(kind); + return (defaultGetKind(operation) ?? []).includes(kind); + } + + referenceSymbol(symbolIdOrSelector: number | Selector): Symbol { + return this.gen.symbols.reference(symbolIdOrSelector); + } + + registerSymbol(symbol: SymbolIn): Symbol { + return this.gen.symbols.register({ + ...symbol, + exportFrom: + symbol.exportFrom ?? + (!symbol.external && + this.context.config.output.indexFile && + this.config.exportFromIndex + ? ['index'] + : undefined), + getFilePath: symbol.getFilePath ?? this.hooks.symbol.getFilePath, + meta: { + pluginName: path.isAbsolute(this.name) ? 'custom' : this.name, + ...symbol.meta, + }, + }); } /** @@ -304,4 +373,15 @@ export class PluginInstance { async run() { await this.handler({ plugin: this }); } + + setSymbolValue( + idOrSymbol: number | Symbol, + value: unknown, + ): Map { + return this.gen.symbols.setValue(this.symbolToId(idOrSymbol), value); + } + + private symbolToId(idOrSymbol: number | Symbol): number { + return typeof idOrSymbol === 'number' ? idOrSymbol : idOrSymbol.id; + } } diff --git a/packages/openapi-ts/src/plugins/types.d.ts b/packages/openapi-ts/src/plugins/types.d.ts index b64aec43a..fc0c76cb7 100644 --- a/packages/openapi-ts/src/plugins/types.d.ts +++ b/packages/openapi-ts/src/plugins/types.d.ts @@ -61,7 +61,6 @@ type BaseConfig = { */ exportFromIndex?: boolean; name: AnyPluginName; - output?: string; /** * Optional hooks to override default plugin behavior. * @@ -85,7 +84,7 @@ export namespace Plugin { handler: Handler; handlerLegacy?: LegacyHandler; name: T['config']['name']; - output: NonNullable; + output?: NonNullable; /** * Resolves static configuration values into their runtime equivalents. For * example, when `validator` is set to `true`, it figures out which plugin diff --git a/packages/openapi-ts/src/plugins/valibot/api.ts b/packages/openapi-ts/src/plugins/valibot/api.ts index 78b24d390..be4b955e8 100644 --- a/packages/openapi-ts/src/plugins/valibot/api.ts +++ b/packages/openapi-ts/src/plugins/valibot/api.ts @@ -1,7 +1,4 @@ -import type { - ICodegenFile, - ICodegenSymbolSelector, -} from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { IR } from '../../ir/types'; @@ -13,7 +10,6 @@ import type { ValibotPlugin } from './types'; type SelectorType = 'data' | 'import' | 'ref' | 'responses' | 'webhook-request'; type ValidatorArgs = { - file: ICodegenFile; operation: IR.OperationObject; plugin: ValibotPlugin['Instance']; }; @@ -33,32 +29,24 @@ export type IApi = { * - `webhook-request`: `operation.id` string * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'valibot'>) {} createRequestValidator({ - file, operation, plugin, }: ValidatorArgs): ts.ArrowFunction | undefined { - const symbol = plugin.gen.selectSymbolFirst( + const symbol = plugin.getSymbol( 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 vSymbol = plugin.referenceSymbol( + plugin.api.getSelector('import', 'valibot'), + ); const dataParameterName = 'data'; @@ -89,25 +77,17 @@ export class Api implements IApi { } createResponseValidator({ - file, operation, plugin, }: ValidatorArgs): ts.ArrowFunction | undefined { - const symbol = plugin.gen.selectSymbolFirst( + const symbol = plugin.getSymbol( 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 vSymbol = plugin.referenceSymbol( + plugin.api.getSelector('import', 'valibot'), + ); const dataParameterName = 'data'; @@ -137,9 +117,7 @@ export class Api implements IApi { }); } - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } diff --git a/packages/openapi-ts/src/plugins/valibot/config.ts b/packages/openapi-ts/src/plugins/valibot/config.ts index 6b45870d1..a6f4d85f6 100644 --- a/packages/openapi-ts/src/plugins/valibot/config.ts +++ b/packages/openapi-ts/src/plugins/valibot/config.ts @@ -15,7 +15,6 @@ export const defaultConfig: ValibotPlugin['Config'] = { }, handler, name: 'valibot', - output: 'valibot', resolveConfig: (plugin, context) => { plugin.config.definitions = context.valueToObject({ defaultValue: { diff --git a/packages/openapi-ts/src/plugins/valibot/operation.ts b/packages/openapi-ts/src/plugins/valibot/operation.ts index 033ec060e..02770a559 100644 --- a/packages/openapi-ts/src/plugins/valibot/operation.ts +++ b/packages/openapi-ts/src/plugins/valibot/operation.ts @@ -111,8 +111,8 @@ export const operationToValibotSchema = ({ schemaData.required = [...requiredProperties]; - const f = plugin.gen.ensureFile(plugin.output); - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.requests, name: operation.id, @@ -120,8 +120,6 @@ export const operationToValibotSchema = ({ selector: plugin.api.getSelector('data', operation.id), }); schemaToValibotSchema({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/valibot-data/${operation.id}`, plugin, schema: schemaData, state, @@ -134,8 +132,8 @@ export const operationToValibotSchema = ({ const { response } = operationResponsesMap(operation); if (response) { - const f = plugin.gen.ensureFile(plugin.output); - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.responses, name: operation.id, @@ -143,8 +141,6 @@ export const operationToValibotSchema = ({ selector: plugin.api.getSelector('responses', operation.id), }); schemaToValibotSchema({ - // TODO: refactor for better cross-plugin compatibility - $ref: `#/valibot-response/${operation.id}`, plugin, schema: response, state, diff --git a/packages/openapi-ts/src/plugins/valibot/plugin.ts b/packages/openapi-ts/src/plugins/valibot/plugin.ts index f45ac4496..dac9266d5 100644 --- a/packages/openapi-ts/src/plugins/valibot/plugin.ts +++ b/packages/openapi-ts/src/plugins/valibot/plugin.ts @@ -1,7 +1,6 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; 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'; @@ -44,7 +43,7 @@ const pipesToExpression = ({ return pipes[0]!; } - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); const expression = tsc.callExpression({ @@ -66,7 +65,7 @@ const arrayTypeToValibotSchema = ({ schema: SchemaWithType<'array'>; state: State; }): ts.Expression => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); const functionName = tsc.propertyAccessExpression({ @@ -177,7 +176,7 @@ const booleanTypeToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'boolean'>; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -234,7 +233,7 @@ const enumTypeToValibotSchema = ({ }); } - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -270,7 +269,7 @@ const neverTypeToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'never'>; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); const expression = tsc.callExpression({ @@ -288,7 +287,7 @@ const nullTypeToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'null'>; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); const expression = tsc.callExpression({ @@ -312,7 +311,7 @@ const numberTypeToValibotSchema = ({ const isBigInt = needsBigIntForFormat(format); const formatInfo = isIntegerFormat(format) ? INTEGER_FORMATS[format] : null; - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -597,7 +596,7 @@ const objectTypeToValibotSchema = ({ ); } - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -654,7 +653,7 @@ const stringTypeToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'string'>; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -793,7 +792,7 @@ const tupleTypeToValibotSchema = ({ schema: SchemaWithType<'tuple'>; state: State; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -858,7 +857,7 @@ const undefinedTypeToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'undefined'>; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -877,7 +876,7 @@ const unknownTypeToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'unknown'>; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -896,7 +895,7 @@ const voidTypeToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: SchemaWithType<'void'>; }) => { - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -1041,10 +1040,8 @@ export const schemaToValibotSchema = ({ plugin: ValibotPlugin['Instance']; schema: IR.SchemaObject; state: State; - symbol?: ICodegenSymbolOut; + symbol?: Symbol; }): Array => { - const f = plugin.gen.ensureFile(plugin.output); - let anyType: string | undefined; let pipes: Array = []; @@ -1053,22 +1050,13 @@ export const schemaToValibotSchema = ({ 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, - }); + if (!plugin.getSymbol(selector)) { + symbol = plugin.referenceSymbol(selector); } } } - const vSymbol = plugin.gen.selectSymbolFirstOrThrow( + const vSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'valibot'), ); @@ -1079,7 +1067,7 @@ export const schemaToValibotSchema = ({ // "Block-scoped variable used before its declaration." error // this could be (maybe?) fixed by reshuffling the generation order const selector = plugin.api.getSelector('ref', schema.$ref); - let refSymbol = plugin.gen.selectSymbolFirst(selector); + let refSymbol = plugin.getSymbol(selector); if (!refSymbol) { const ref = plugin.context.resolveIrRef(schema.$ref); const schemaPipes = schemaToValibotSchema({ @@ -1090,7 +1078,7 @@ export const schemaToValibotSchema = ({ }); pipes.push(...schemaPipes); - refSymbol = plugin.gen.selectSymbolFirst(selector); + refSymbol = plugin.getSymbol(selector); } if (refSymbol) { @@ -1251,11 +1239,24 @@ export const schemaToValibotSchema = ({ } if (symbol) { + if ($ref) { + symbol = plugin.registerSymbol({ + exported: true, + name: buildName({ + config: { + case: state.nameCase, + name: state.nameTransformer, + }, + name: refToName($ref), + }), + selector: plugin.api.getSelector('ref', $ref), + }); + } const statement = tsc.constVariable({ comment: plugin.config.comments ? createSchemaComment({ schema }) : undefined, - exportConst: true, + exportConst: symbol.exported, expression: pipesToExpression({ pipes, plugin }), name: symbol.placeholder, typeName: state.hasCircularReference @@ -1265,7 +1266,7 @@ export const schemaToValibotSchema = ({ }) as unknown as ts.TypeNode) : undefined, }); - symbol.update({ value: statement }); + plugin.setSymbolValue(symbol, statement); return []; } @@ -1273,17 +1274,12 @@ export const schemaToValibotSchema = ({ }; export const handler: ValibotPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - - const vSymbol = f.ensureSymbol({ + plugin.registerSymbol({ + external: 'valibot', + meta: { importKind: 'namespace' }, name: 'v', selector: plugin.api.getSelector('import', 'valibot'), }); - f.addImport({ from: 'valibot', namespaceImport: vSymbol.placeholder }); plugin.forEach( 'operation', @@ -1341,9 +1337,4 @@ export const handler: ValibotPlugin['Handler'] = ({ 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/valibot/types.d.ts b/packages/openapi-ts/src/plugins/valibot/types.d.ts index 77aa179e6..2d560d4ea 100644 --- a/packages/openapi-ts/src/plugins/valibot/types.d.ts +++ b/packages/openapi-ts/src/plugins/valibot/types.d.ts @@ -2,278 +2,180 @@ import type { StringCase, StringName } from '../../types/case'; import type { DefinePlugin, Plugin } from '../types'; import type { IApi } from './api'; -export type UserConfig = Plugin.Name<'valibot'> & { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Add comments from input to the generated Valibot schemas? - * - * @default true - */ - comments?: boolean; - /** - * Configuration for reusable schema definitions. - * - * Controls generation of shared Valibot schemas that can be referenced - * across requests and responses. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - */ - definitions?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Valibot schemas for reusable definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the schema name. - * - * @default 'v{{name}}' - */ - name?: StringName; - }; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default false - */ - exportFromIndex?: boolean; - /** - * Enable Valibot metadata support? It's often useful to associate a schema - * with some additional metadata for documentation, code generation, AI - * structured outputs, form validation, and other purposes. - * - * @default false - */ - metadata?: boolean; - /** - * Name of the generated file. - * - * @default 'valibot' - */ - output?: string; - /** - * Configuration for request-specific Valibot schemas. - * - * Controls generation of Valibot schemas for request bodies, query - * parameters, path parameters, and headers. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - */ - requests?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Valibot schemas for request definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the operation name. - * - * @default 'v{{name}}Data' - */ - name?: StringName; - }; - /** - * Configuration for response-specific Valibot schemas. - * - * Controls generation of Valibot schemas for response bodies, error - * responses, and status codes. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - */ - responses?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Valibot schemas for response definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the operation name. - * - * @default 'v{{name}}Response' - */ - name?: StringName; - }; - /** - * Configuration for webhook-specific Valibot schemas. - * - * Controls generation of Valibot schemas for webhook payloads. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default true - */ - webhooks?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Valibot schemas for webhook definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the webhook key. - * - * @default 'v{{name}}WebhookRequest' - */ - name?: StringName; - }; -}; - -export type Config = Plugin.Name<'valibot'> & { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case: StringCase; - /** - * Add comments from input to the generated Valibot schemas? - * - * @default true - */ - comments: boolean; - /** - * Configuration for reusable schema definitions. - * - * Controls generation of shared Valibot schemas that can be referenced - * across requests and responses. - */ - definitions: { +export type UserConfig = Plugin.Name<'valibot'> & + Plugin.Hooks & { /** * The casing convention to use for generated names. * * @default 'camelCase' */ - case: StringCase; + case?: StringCase; /** - * Whether to generate Valibot schemas for reusable definitions. + * Add comments from input to the generated Valibot schemas? * * @default true */ - enabled: boolean; + comments?: boolean; /** - * Custom naming pattern for generated schema names. The name variable is - * obtained from the schema name. + * Configuration for reusable schema definitions. * - * @default 'v{{name}}' + * Controls generation of shared Valibot schemas that can be referenced + * across requests and responses. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object */ - name: StringName; - }; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default false - */ - exportFromIndex: boolean; - /** - * Enable Valibot metadata support? It's often useful to associate a schema - * with some additional metadata for documentation, code generation, AI - * structured outputs, form validation, and other purposes. - * - * @default false - */ - metadata: boolean; - /** - * Name of the generated file. - * - * @default 'valibot' - */ - output: string; - /** - * Configuration for request-specific Valibot schemas. - * - * Controls generation of Valibot schemas for request bodies, query - * parameters, path parameters, and headers. - */ - requests: { + definitions?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case?: StringCase; + /** + * Whether to generate Valibot schemas for reusable definitions. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated schema names. The name variable + * is obtained from the schema name. + * + * @default 'v{{name}}' + */ + name?: StringName; + }; /** - * The casing convention to use for generated names. + * Should the exports from the generated files be re-exported in the index + * barrel file? * - * @default 'camelCase' + * @default false */ - case: StringCase; + exportFromIndex?: boolean; /** - * Whether to generate Valibot schemas for request definitions. + * Enable Valibot metadata support? It's often useful to associate a schema + * with some additional metadata for documentation, code generation, AI + * structured outputs, form validation, and other purposes. * - * @default true + * @default false */ - enabled: boolean; + metadata?: boolean; /** - * Custom naming pattern for generated schema names. The name variable is - * obtained from the operation name. + * Configuration for request-specific Valibot schemas. * - * @default 'v{{name}}Data' + * Controls generation of Valibot schemas for request bodies, query + * parameters, path parameters, and headers. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + */ + requests?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case?: StringCase; + /** + * Whether to generate Valibot schemas for request definitions. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated schema names. The name variable + * is obtained from the operation name. + * + * @default 'v{{name}}Data' + */ + name?: StringName; + }; + /** + * Configuration for response-specific Valibot schemas. + * + * Controls generation of Valibot schemas for response bodies, error + * responses, and status codes. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object */ - name: StringName; + responses?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case?: StringCase; + /** + * Whether to generate Valibot schemas for response definitions. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated schema names. The name variable + * is obtained from the operation name. + * + * @default 'v{{name}}Response' + */ + name?: StringName; + }; + /** + * Configuration for webhook-specific Valibot schemas. + * + * Controls generation of Valibot schemas for webhook payloads. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default true + */ + webhooks?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case?: StringCase; + /** + * Whether to generate Valibot schemas for webhook definitions. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated schema names. The name variable + * is obtained from the webhook key. + * + * @default 'v{{name}}WebhookRequest' + */ + name?: StringName; + }; }; - /** - * Configuration for response-specific Valibot schemas. - * - * Controls generation of Valibot schemas for response bodies, error - * responses, and status codes. - */ - responses: { + +export type Config = Plugin.Name<'valibot'> & + Plugin.Hooks & { /** * The casing convention to use for generated names. * @@ -281,45 +183,133 @@ export type Config = Plugin.Name<'valibot'> & { */ case: StringCase; /** - * Whether to generate Valibot schemas for response definitions. + * Add comments from input to the generated Valibot schemas? * * @default true */ - enabled: boolean; + comments: boolean; /** - * Custom naming pattern for generated schema names. The name variable is - * obtained from the operation name. + * Configuration for reusable schema definitions. * - * @default 'v{{name}}Response' + * Controls generation of shared Valibot schemas that can be referenced + * across requests and responses. */ - name: StringName; - }; - /** - * Configuration for webhook-specific Valibot schemas. - * - * Controls generation of Valibot schemas for webhook payloads. - */ - webhooks: { + definitions: { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case: StringCase; + /** + * Whether to generate Valibot schemas for reusable definitions. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable is + * obtained from the schema name. + * + * @default 'v{{name}}' + */ + name: StringName; + }; /** - * The casing convention to use for generated names. + * Should the exports from the generated files be re-exported in the index + * barrel file? * - * @default 'camelCase' + * @default false */ - case: StringCase; + exportFromIndex: boolean; /** - * Whether to generate Valibot schemas for webhook definitions. + * Enable Valibot metadata support? It's often useful to associate a schema + * with some additional metadata for documentation, code generation, AI + * structured outputs, form validation, and other purposes. * - * @default true + * @default false + */ + metadata: boolean; + /** + * Configuration for request-specific Valibot schemas. + * + * Controls generation of Valibot schemas for request bodies, query + * parameters, path parameters, and headers. + */ + requests: { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case: StringCase; + /** + * Whether to generate Valibot schemas for request definitions. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable is + * obtained from the operation name. + * + * @default 'v{{name}}Data' + */ + name: StringName; + }; + /** + * Configuration for response-specific Valibot schemas. + * + * Controls generation of Valibot schemas for response bodies, error + * responses, and status codes. */ - enabled: boolean; + responses: { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case: StringCase; + /** + * Whether to generate Valibot schemas for response definitions. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable is + * obtained from the operation name. + * + * @default 'v{{name}}Response' + */ + name: StringName; + }; /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the webhook key. + * Configuration for webhook-specific Valibot schemas. * - * @default 'v{{name}}WebhookRequest' + * Controls generation of Valibot schemas for webhook payloads. */ - name: StringName; + webhooks: { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case: StringCase; + /** + * Whether to generate Valibot schemas for webhook definitions. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable + * is obtained from the webhook key. + * + * @default 'v{{name}}WebhookRequest' + */ + name: StringName; + }; }; -}; 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 0aae05ee4..9d64064fa 100644 --- a/packages/openapi-ts/src/plugins/valibot/webhook.ts +++ b/packages/openapi-ts/src/plugins/valibot/webhook.ts @@ -110,16 +110,15 @@ export const webhookToValibotSchema = ({ schemaData.required = [...requiredProperties]; - const selector = plugin.api.getSelector('webhook-request', operation.id); - const name = buildName({ - config: plugin.config.webhooks, - name: operation.id, + const symbol = plugin.registerSymbol({ + exported: true, + name: buildName({ + config: plugin.config.webhooks, + name: operation.id, + }), + selector: plugin.api.getSelector('webhook-request', 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}`, plugin, schema: schemaData, state, diff --git a/packages/openapi-ts/src/plugins/zod/api.ts b/packages/openapi-ts/src/plugins/zod/api.ts index 2e938cfaf..0c78dc943 100644 --- a/packages/openapi-ts/src/plugins/zod/api.ts +++ b/packages/openapi-ts/src/plugins/zod/api.ts @@ -1,7 +1,4 @@ -import type { - ICodegenFile, - ICodegenSymbolSelector, -} from '@hey-api/codegen-core'; +import type { Selector } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { IR } from '../../ir/types'; @@ -22,7 +19,6 @@ type SelectorType = | 'webhook-request'; type ValidatorArgs = { - file: ICodegenFile; operation: IR.OperationObject; plugin: ZodPlugin['Instance']; }; @@ -46,27 +42,21 @@ export type IApi = { * - `webhook-request`: `operation.id` string * @returns Selector array */ - getSelector: (type: SelectorType, value?: string) => ICodegenSymbolSelector; + getSelector: (type: SelectorType, value?: string) => Selector; }; export class Api implements IApi { constructor(public meta: Plugin.Name<'zod'>) {} createRequestValidator({ - file, operation, plugin, }: ValidatorArgs): ts.ArrowFunction | undefined { - const symbol = plugin.gen.selectSymbolFirst( + const symbol = plugin.getSymbol( plugin.api.getSelector('data', operation.id), ); if (!symbol) return; - file.addImport({ - from: symbol.file, - names: [symbol.placeholder], - }); - const dataParameterName = 'data'; return tsc.arrowFunction({ @@ -93,20 +83,14 @@ export class Api implements IApi { } createResponseValidator({ - file, operation, plugin, }: ValidatorArgs): ts.ArrowFunction | undefined { - const symbol = plugin.gen.selectSymbolFirst( + const symbol = plugin.getSymbol( plugin.api.getSelector('responses', operation.id), ); if (!symbol) return; - file.addImport({ - from: symbol.file, - names: [symbol.placeholder], - }); - const dataParameterName = 'data'; return tsc.arrowFunction({ @@ -132,9 +116,7 @@ export class Api implements IApi { }); } - getSelector( - ...args: ReadonlyArray - ): ICodegenSymbolSelector { - return [this.meta.name, ...(args as ICodegenSymbolSelector)]; + getSelector(...args: ReadonlyArray): Selector { + return [this.meta.name, ...(args as Selector)]; } } diff --git a/packages/openapi-ts/src/plugins/zod/config.ts b/packages/openapi-ts/src/plugins/zod/config.ts index 585fb1f5a..a025ed339 100644 --- a/packages/openapi-ts/src/plugins/zod/config.ts +++ b/packages/openapi-ts/src/plugins/zod/config.ts @@ -21,7 +21,6 @@ export const defaultConfig: ZodPlugin['Config'] = { }, handler, name: 'zod', - output: 'zod', resolveConfig: (plugin, context) => { const packageName = 'zod'; const version = context.package.getVersion(packageName); diff --git a/packages/openapi-ts/src/plugins/zod/export.ts b/packages/openapi-ts/src/plugins/zod/export.ts index 676229b4f..21c836849 100644 --- a/packages/openapi-ts/src/plugins/zod/export.ts +++ b/packages/openapi-ts/src/plugins/zod/export.ts @@ -1,4 +1,4 @@ -import type { ICodegenSymbolOut } from '@hey-api/codegen-core'; +import type { Symbol } from '@hey-api/codegen-core'; import type ts from 'typescript'; import type { IR } from '../../ir/types'; @@ -17,11 +17,11 @@ export const exportZodSchema = ({ }: { plugin: ZodPlugin['Instance']; schema: IR.SchemaObject; - symbol: ICodegenSymbolOut; - typeInferSymbol: ICodegenSymbolOut | undefined; + symbol: Symbol; + typeInferSymbol: Symbol | undefined; zodSchema: ZodSchema; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -29,7 +29,7 @@ export const exportZodSchema = ({ comment: plugin.config.comments ? createSchemaComment({ schema }) : undefined, - exportConst: true, + exportConst: symbol.exported, expression: zodSchema.expression, name: symbol.placeholder, typeName: zodSchema.typeName @@ -39,11 +39,11 @@ export const exportZodSchema = ({ }) as unknown as ts.TypeNode) : undefined, }); - symbol.update({ value: statement }); + plugin.setSymbolValue(symbol, statement); if (typeInferSymbol) { const inferType = tsc.typeAliasDeclaration({ - exportType: true, + exportType: typeInferSymbol.exported, name: typeInferSymbol.placeholder, type: tsc.typeReferenceNode({ typeArguments: [ @@ -57,6 +57,6 @@ export const exportZodSchema = ({ }) as unknown as string, }), }); - typeInferSymbol.update({ value: inferType }); + plugin.setSymbolValue(typeInferSymbol, inferType); } }; diff --git a/packages/openapi-ts/src/plugins/zod/mini/plugin.ts b/packages/openapi-ts/src/plugins/zod/mini/plugin.ts index 1a1f6bfd3..1fdb02e02 100644 --- a/packages/openapi-ts/src/plugins/zod/mini/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/mini/plugin.ts @@ -1,6 +1,5 @@ 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'; @@ -24,7 +23,7 @@ const arrayTypeToZodSchema = ({ schema: SchemaWithType<'array'>; state: State; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -156,7 +155,7 @@ const booleanTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'boolean'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -189,7 +188,7 @@ const enumTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'enum'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -253,7 +252,7 @@ const neverTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'never'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const result: Partial> = {}; @@ -272,7 +271,7 @@ const nullTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'null'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const result: Partial> = {}; @@ -317,7 +316,7 @@ const numberTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'integer' | 'number'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -433,7 +432,7 @@ const objectTypeToZodSchema = ({ schema: SchemaWithType<'object'>; state: State; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -556,7 +555,7 @@ const stringTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'string'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -747,7 +746,7 @@ const tupleTypeToZodSchema = ({ schema: SchemaWithType<'tuple'>; state: State; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -813,7 +812,7 @@ const undefinedTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'undefined'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const result: Partial> = {}; @@ -832,7 +831,7 @@ const unknownTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'unknown'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const result: Partial> = {}; @@ -851,7 +850,7 @@ const voidTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'void'>; }): Omit => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const result: Partial> = {}; @@ -957,11 +956,9 @@ const schemaToZodSchema = ({ schema: IR.SchemaObject; state: State; }): ZodSchema => { - const f = plugin.gen.ensureFile(plugin.output); - let zodSchema: Partial = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -974,11 +971,11 @@ const schemaToZodSchema = ({ state.currentReferenceTracker.push(schema.$ref); const selector = plugin.api.getSelector('ref', schema.$ref); - let symbol = plugin.gen.selectSymbolFirst(selector); + let symbol = plugin.getSymbol(selector); if (isCircularReference) { if (!symbol) { - symbol = f.ensureSymbol({ selector }); + symbol = plugin.referenceSymbol(selector); } if (isSelfReference) { @@ -1001,23 +998,25 @@ const schemaToZodSchema = ({ } else { zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); } - zodSchema.hasCircularReference = true; - } 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 - const ref = plugin.context.resolveIrRef(schema.$ref); - handleComponent({ - id: schema.$ref, - plugin, - schema: ref, - state, - }); - } + zodSchema.hasCircularReference = schema.circular; + } 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 + const ref = plugin.context.resolveIrRef(schema.$ref); + handleComponent({ + id: schema.$ref, + plugin, + schema: ref, + state, + }); + } else { + zodSchema.hasCircularReference = schema.circular; + } - if (!isCircularReference) { - const symbol = plugin.gen.selectSymbolFirstOrThrow(selector); - zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); + const refSymbol = plugin.referenceSymbol(selector); + zodSchema.expression = tsc.identifier({ text: refSymbol.placeholder }); } state.circularReferenceTracker.pop(); @@ -1053,13 +1052,12 @@ const schemaToZodSchema = ({ schema = deduplicateSchema({ schema }); if (schema.items) { - const itemTypes = schema.items.map( - (item) => - schemaToZodSchema({ - plugin, - schema: item, - state, - }).expression, + const itemSchemas = schema.items.map((item) => + schemaToZodSchema({ + plugin, + schema: item, + state, + }), ); if (schema.logicalOperator === 'and') { @@ -1076,17 +1074,36 @@ const schemaToZodSchema = ({ expression: zSymbol.placeholder, name: identifiers.intersection, }), - parameters: itemTypes, + parameters: itemSchemas.map((schema) => schema.expression), }); } else { - zodSchema.expression = itemTypes[0]; - itemTypes.slice(1).forEach((item) => { + zodSchema.expression = itemSchemas[0]!.expression; + itemSchemas.slice(1).forEach((schema) => { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: zSymbol.placeholder, name: identifiers.intersection, }), - parameters: [zodSchema.expression, item], + parameters: [ + zodSchema.expression, + schema.hasCircularReference + ? tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: zSymbol.placeholder, + name: identifiers.lazy, + }), + parameters: [ + tsc.arrowFunction({ + statements: [ + tsc.returnStatement({ + expression: schema.expression, + }), + ], + }), + ], + }) + : schema.expression, + ], }); }); } @@ -1098,7 +1115,7 @@ const schemaToZodSchema = ({ }), parameters: [ tsc.arrayLiteralExpression({ - elements: itemTypes, + elements: itemSchemas.map((schema) => schema.expression), }), ], }); @@ -1180,21 +1197,25 @@ const handleComponent = ({ }; const selector = plugin.api.getSelector('ref', id); - let symbol = plugin.gen.selectSymbolFirst(selector); - if (symbol && !symbol.headless) return; + let symbol = plugin.getSymbol(selector); + if (symbol && !plugin.getSymbolValue(symbol)) return; const zodSchema = schemaToZodSchema({ plugin, schema, state }); - const f = plugin.gen.ensureFile(plugin.output); const baseName = refToName(id); - symbol = f.ensureSymbol({ selector }); - symbol = symbol.update({ + symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.definitions, name: baseName, }), + selector, }); const typeInferSymbol = plugin.config.definitions.types.infer.enabled - ? f.addSymbol({ + ? plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.definitions.types.infer, name: baseName, @@ -1212,20 +1233,12 @@ const handleComponent = ({ }; export const handlerMini: ZodPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - - const zSymbol = f.ensureSymbol({ + plugin.registerSymbol({ + external: getZodModule({ plugin }), + meta: { importKind: 'namespace' }, name: 'z', selector: plugin.api.getSelector('import', 'zod'), }); - f.addImport({ - from: getZodModule({ plugin }), - namespaceImport: zSymbol.placeholder, - }); plugin.forEach( 'operation', @@ -1287,9 +1300,4 @@ export const handlerMini: ZodPlugin['Handler'] = ({ 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/zod/shared/operation.ts b/packages/openapi-ts/src/plugins/zod/shared/operation.ts index 89215872d..b4b4f7dd1 100644 --- a/packages/openapi-ts/src/plugins/zod/shared/operation.ts +++ b/packages/openapi-ts/src/plugins/zod/shared/operation.ts @@ -14,8 +14,6 @@ export const operationToZodSchema = ({ operation: IR.OperationObject; plugin: ZodPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(plugin.output); - if (plugin.config.requests.enabled) { const requiredProperties = new Set(); @@ -115,7 +113,8 @@ export const operationToZodSchema = ({ schemaData.required = [...requiredProperties]; const zodSchema = getZodSchema(schemaData); - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.requests, name: operation.id, @@ -123,7 +122,11 @@ export const operationToZodSchema = ({ selector: plugin.api.getSelector('data', operation.id), }); const typeInferSymbol = plugin.config.requests.types.infer.enabled - ? f.addSymbol({ + ? plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.requests.types.infer, name: operation.id, @@ -146,7 +149,8 @@ export const operationToZodSchema = ({ if (response) { const zodSchema = getZodSchema(response); - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.responses, name: operation.id, @@ -154,7 +158,11 @@ export const operationToZodSchema = ({ selector: plugin.api.getSelector('responses', operation.id), }); const typeInferSymbol = plugin.config.responses.types.infer.enabled - ? f.addSymbol({ + ? plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: 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 5e8374943..fc753cffb 100644 --- a/packages/openapi-ts/src/plugins/zod/shared/webhook.ts +++ b/packages/openapi-ts/src/plugins/zod/shared/webhook.ts @@ -13,8 +13,6 @@ export const webhookToZodSchema = ({ operation: IR.OperationObject; plugin: ZodPlugin['Instance']; }) => { - const f = plugin.gen.ensureFile(plugin.output); - if (plugin.config.webhooks.enabled) { const requiredProperties = new Set(); @@ -114,7 +112,8 @@ export const webhookToZodSchema = ({ schemaData.required = [...requiredProperties]; const zodSchema = getZodSchema(schemaData); - const symbol = f.addSymbol({ + const symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.webhooks, name: operation.id, @@ -122,7 +121,11 @@ export const webhookToZodSchema = ({ selector: plugin.api.getSelector('webhook-request', operation.id), }); const typeInferSymbol = plugin.config.webhooks.types.infer.enabled - ? f.addSymbol({ + ? plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: 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 df4eb05e0..e5bc03a25 100644 --- a/packages/openapi-ts/src/plugins/zod/types.d.ts +++ b/packages/openapi-ts/src/plugins/zod/types.d.ts @@ -2,481 +2,421 @@ import type { StringCase, StringName } from '../../types/case'; import type { DefinePlugin, Plugin } from '../types'; import type { IApi } from './api'; -export type UserConfig = Plugin.Name<'zod'> & { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Add comments from input to the generated Zod schemas? - * - * @default true - */ - comments?: boolean; - /** - * The compatibility version to target for generated output. - * - * Can be: - * - `4`: [Zod 4](https://zod.dev/packages/zod) (default). - * - `3`: [Zod 3](https://v3.zod.dev/). - * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini). - * - * @default 4 - */ - compatibilityVersion?: 3 | 4 | 'mini'; - /** - * Configuration for date handling in generated Zod schemas. - * - * Controls how date values are processed and validated using Zod's - * date validation features. - */ - dates?: { +export type UserConfig = Plugin.Name<'zod'> & + Plugin.Hooks & { /** - * Whether to allow unqualified (timezone-less) datetimes: + * The casing convention to use for generated names. * - * When enabled, Zod will accept datetime strings without timezone information. - * When disabled, Zod will require timezone information in datetime strings. + * @default 'camelCase' + */ + case?: StringCase; + /** + * Add comments from input to the generated Zod schemas? * - * @default false + * @default true */ - local?: boolean; + comments?: boolean; /** - * Whether to include timezone offset information when handling dates. + * The compatibility version to target for generated output. * - * When enabled, date strings will preserve timezone information. - * When disabled, dates will be treated as local time. + * Can be: + * - `4`: [Zod 4](https://zod.dev/packages/zod) (default). + * - `3`: [Zod 3](https://v3.zod.dev/). + * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini). * - * @default false + * @default 4 */ - offset?: boolean; - }; - /** - * Configuration for reusable schema definitions. - * - * Controls generation of shared Zod schemas that can be referenced across - * requests and responses. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default true - */ - definitions?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Zod schemas for reusable definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the schema name. - * - * @default 'z{{name}}' - */ - name?: StringName; - /** - * Configuration for TypeScript type generation from Zod schemas. - * - * Controls generation of TypeScript types based on the generated Zod schemas. - */ - types?: { + compatibilityVersion?: 3 | 4 | 'mini'; + /** + * Configuration for date handling in generated Zod schemas. + * + * Controls how date values are processed and validated using Zod's + * date validation features. + */ + dates?: { + /** + * Whether to allow unqualified (timezone-less) datetimes: + * + * When enabled, Zod will accept datetime strings without timezone information. + * When disabled, Zod will require timezone information in datetime strings. + * + * @default false + */ + local?: boolean; + /** + * Whether to include timezone offset information when handling dates. + * + * When enabled, date strings will preserve timezone information. + * When disabled, dates will be treated as local time. + * + * @default false + */ + offset?: boolean; + }; + /** + * Configuration for reusable schema definitions. + * + * Controls generation of shared Zod schemas that can be referenced across + * requests and responses. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default true + */ + definitions?: + | boolean + | StringName + | { /** - * Configuration for `z.infer` types. + * The casing convention to use for generated names. * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object + * @default 'camelCase' + */ + case?: StringCase; + /** + * Whether to generate Zod schemas for reusable definitions. * - * @default false + * @default true */ - infer?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Whether to generate TypeScript types from Zod schemas. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}ZodType' - */ - name?: StringName; - }; - }; - }; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default false - */ - exportFromIndex?: boolean; - /** - * Enable Zod metadata support? It's often useful to associate a schema with - * some additional metadata for documentation, code generation, AI - * structured outputs, form validation, and other purposes. - * - * @default false - */ - metadata?: boolean; - /** - * Name of the generated file. - * - * @default 'zod' - */ - output?: string; - /** - * Configuration for request-specific Zod schemas. - * - * Controls generation of Zod schemas for request bodies, query parameters, path - * parameters, and headers. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default true - */ - requests?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Zod schemas for request definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the operation name. - * - * @default 'z{{name}}Data' - */ - name?: StringName; - /** - * Configuration for TypeScript type generation from Zod schemas. - * - * Controls generation of TypeScript types based on the generated Zod schemas. - */ - types?: { + enabled?: boolean; /** - * Configuration for `z.infer` types. + * Custom naming pattern for generated schema names. The name variable + * is obtained from the schema name. * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object + * @default 'z{{name}}' + */ + name?: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. * - * @default false + * Controls generation of TypeScript types based on the generated Zod schemas. */ - infer?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Whether to generate TypeScript types from Zod schemas. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}DataZodType' - */ - name?: StringName; - }; + types?: { + /** + * Configuration for `z.infer` types. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default false + */ + infer?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}ZodType' + */ + name?: StringName; + }; + }; }; - }; - /** - * Configuration for response-specific Zod schemas. - * - * Controls generation of Zod schemas for response bodies, error responses, - * and status codes. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default true - */ - responses?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Zod schemas for response definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the operation name. - * - * @default 'z{{name}}Response' - */ - name?: StringName; - /** - * Configuration for TypeScript type generation from Zod schemas. - * - * Controls generation of TypeScript types based on the generated Zod schemas. - */ - types?: { + /** + * Should the exports from the generated files be re-exported in the index + * barrel file? + * + * @default false + */ + exportFromIndex?: boolean; + /** + * Enable Zod metadata support? It's often useful to associate a schema with + * some additional metadata for documentation, code generation, AI + * structured outputs, form validation, and other purposes. + * + * @default false + */ + metadata?: boolean; + /** + * Configuration for request-specific Zod schemas. + * + * Controls generation of Zod schemas for request bodies, query parameters, path + * parameters, and headers. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default true + */ + requests?: + | boolean + | StringName + | { /** - * Configuration for `z.infer` types. + * The casing convention to use for generated names. * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object + * @default 'camelCase' + */ + case?: StringCase; + /** + * Whether to generate Zod schemas for request definitions. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated schema names. The name variable + * is obtained from the operation name. * - * @default false + * @default 'z{{name}}Data' */ - infer?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Whether to generate TypeScript types from Zod schemas. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}ResponseZodType' - */ - name?: StringName; - }; + name?: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. + * + * Controls generation of TypeScript types based on the generated Zod schemas. + */ + types?: { + /** + * Configuration for `z.infer` types. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default false + */ + infer?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}DataZodType' + */ + name?: StringName; + }; + }; }; - }; - /** - * Configuration for TypeScript type generation from Zod schemas. - * - * Controls generation of TypeScript types based on the generated Zod schemas. - */ - types?: { /** - * Configuration for `z.infer` types. + * Configuration for response-specific Zod schemas. + * + * Controls generation of Zod schemas for response bodies, error responses, + * and status codes. * * Can be: * - `boolean`: Shorthand for `{ enabled: boolean }` * - `string` or `function`: Shorthand for `{ name: string | function }` * - `object`: Full configuration object * - * @default false + * @default true */ - infer?: + responses?: | boolean | StringName | { /** - * The casing convention to use for generated type names. + * The casing convention to use for generated names. * - * @default 'PascalCase' + * @default 'camelCase' */ case?: StringCase; /** - * Whether to generate TypeScript types from Zod schemas. + * Whether to generate Zod schemas for response definitions. * * @default true */ enabled?: boolean; - }; - }; - /** - * Configuration for webhook-specific Zod schemas. - * - * Controls generation of Zod schemas for webhook payloads. - * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object - * - * @default true - */ - webhooks?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case?: StringCase; - /** - * Whether to generate Zod schemas for webhook definitions. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated schema names. The name variable - * is obtained from the webhook key. - * - * @default 'z{{name}}WebhookRequest' - */ - name?: StringName; - /** - * Configuration for TypeScript type generation from Zod schemas. - * - * Controls generation of TypeScript types based on the generated Zod schemas. - */ - types?: { /** - * Configuration for `z.infer` types. + * Custom naming pattern for generated schema names. The name variable + * is obtained from the operation name. * - * Can be: - * - `boolean`: Shorthand for `{ enabled: boolean }` - * - `string` or `function`: Shorthand for `{ name: string | function }` - * - `object`: Full configuration object + * @default 'z{{name}}Response' + */ + name?: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. * - * @default false + * Controls generation of TypeScript types based on the generated Zod schemas. */ - infer?: - | boolean - | StringName - | { - /** - * The casing convention to use for generated type names. - * - * @default 'PascalCase' - */ - case?: StringCase; - /** - * Whether to generate TypeScript types from Zod schemas. - * - * @default true - */ - enabled?: boolean; - /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}WebhookRequestZodType' - */ - name?: StringName; - }; + types?: { + /** + * Configuration for `z.infer` types. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default false + */ + infer?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}ResponseZodType' + */ + name?: StringName; + }; + }; }; - }; -}; - -export type Config = Plugin.Name<'zod'> & { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case: StringCase; - /** - * Add comments from input to the generated Zod schemas? - * - * @default true - */ - comments: boolean; - /** - * The compatibility version to target for generated output. - * - * Can be: - * - `4`: [Zod 4](https://zod.dev/packages/zod) (default). - * - `3`: [Zod 3](https://v3.zod.dev/). - * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini). - * - * @default 4 - */ - compatibilityVersion: 3 | 4 | 'mini'; - /** - * Configuration for date handling in generated Zod schemas. - * - * Controls how date values are processed and validated using Zod's - * date validation features. - */ - dates: { /** - * Whether to allow unqualified (timezone-less) datetimes: - * - * When enabled, Zod will accept datetime strings without timezone information. - * When disabled, Zod will require timezone information in datetime strings. + * Configuration for TypeScript type generation from Zod schemas. * - * @default false + * Controls generation of TypeScript types based on the generated Zod schemas. */ - local: boolean; + types?: { + /** + * Configuration for `z.infer` types. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default false + */ + infer?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled?: boolean; + }; + }; /** - * Whether to include timezone offset information when handling dates. + * Configuration for webhook-specific Zod schemas. * - * When enabled, date strings will preserve timezone information. - * When disabled, dates will be treated as local time. + * Controls generation of Zod schemas for webhook payloads. * - * @default false + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default true */ - offset: boolean; + webhooks?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case?: StringCase; + /** + * Whether to generate Zod schemas for webhook definitions. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated schema names. The name variable + * is obtained from the webhook key. + * + * @default 'z{{name}}WebhookRequest' + */ + name?: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. + * + * Controls generation of TypeScript types based on the generated Zod schemas. + */ + types?: { + /** + * Configuration for `z.infer` types. + * + * Can be: + * - `boolean`: Shorthand for `{ enabled: boolean }` + * - `string` or `function`: Shorthand for `{ name: string | function }` + * - `object`: Full configuration object + * + * @default false + */ + infer?: + | boolean + | StringName + | { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case?: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled?: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}WebhookRequestZodType' + */ + name?: StringName; + }; + }; + }; }; - /** - * Configuration for reusable schema definitions. - * - * Controls generation of shared Zod schemas that can be referenced across - * requests and responses. - */ - definitions: { + +export type Config = Plugin.Name<'zod'> & + Plugin.Hooks & { /** * The casing convention to use for generated names. * @@ -484,236 +424,237 @@ export type Config = Plugin.Name<'zod'> & { */ case: StringCase; /** - * Whether to generate Zod schemas for reusable definitions. + * Add comments from input to the generated Zod schemas? * * @default true */ - enabled: boolean; + comments: boolean; /** - * Custom naming pattern for generated schema names. The name variable is - * obtained from the schema name. + * The compatibility version to target for generated output. + * + * Can be: + * - `4`: [Zod 4](https://zod.dev/packages/zod) (default). + * - `3`: [Zod 3](https://v3.zod.dev/). + * - `'mini'`: [Zod Mini](https://zod.dev/packages/mini). * - * @default 'z{{name}}' + * @default 4 */ - name: StringName; + compatibilityVersion: 3 | 4 | 'mini'; /** - * Configuration for TypeScript type generation from Zod schemas. + * Configuration for date handling in generated Zod schemas. * - * Controls generation of TypeScript types based on the generated Zod schemas. + * Controls how date values are processed and validated using Zod's + * date validation features. */ - types: { + dates: { /** - * Configuration for `z.infer` types. + * Whether to allow unqualified (timezone-less) datetimes: + * + * When enabled, Zod will accept datetime strings without timezone information. + * When disabled, Zod will require timezone information in datetime strings. + * + * @default false */ - infer: { - /** - * The casing convention to use for generated type names. - * - * @default 'PascalCase' - */ - case: StringCase; - /** - * Whether to generate TypeScript types from Zod schemas. - * - * @default true - */ - enabled: boolean; - /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}ZodType' - */ - name: StringName; - }; + local: boolean; + /** + * Whether to include timezone offset information when handling dates. + * + * When enabled, date strings will preserve timezone information. + * When disabled, dates will be treated as local time. + * + * @default false + */ + offset: boolean; }; - }; - /** - * Should the exports from the generated files be re-exported in the index - * barrel file? - * - * @default false - */ - exportFromIndex: boolean; - /** - * Enable Zod metadata support? It's often useful to associate a schema with - * some additional metadata for documentation, code generation, AI - * structured outputs, form validation, and other purposes. - * - * @default false - */ - metadata: boolean; - /** - * Name of the generated file. - * - * @default 'zod' - */ - output: string; - /** - * Configuration for request-specific Zod schemas. - * - * Controls generation of Zod schemas for request bodies, query parameters, path - * parameters, and headers. - */ - requests: { /** - * The casing convention to use for generated names. + * Configuration for reusable schema definitions. * - * @default 'camelCase' - */ - case: StringCase; - /** - * Whether to generate Zod schemas for request definitions. - * - * @default true - */ - enabled: boolean; - /** - * Custom naming pattern for generated schema names. The name variable is - * obtained from the operation name. - * - * @default 'z{{name}}Data' - */ - name: StringName; - /** - * Configuration for TypeScript type generation from Zod schemas. - * - * Controls generation of TypeScript types based on the generated Zod schemas. + * Controls generation of shared Zod schemas that can be referenced across + * requests and responses. */ - types: { + definitions: { /** - * Configuration for `z.infer` types. + * The casing convention to use for generated names. + * + * @default 'camelCase' */ - infer: { - /** - * The casing convention to use for generated type names. - * - * @default 'PascalCase' - */ - case: StringCase; - /** - * Whether to generate TypeScript types from Zod schemas. - * - * @default true - */ - enabled: boolean; + case: StringCase; + /** + * Whether to generate Zod schemas for reusable definitions. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable is + * obtained from the schema name. + * + * @default 'z{{name}}' + */ + name: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. + * + * Controls generation of TypeScript types based on the generated Zod schemas. + */ + types: { /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}DataZodType' + * Configuration for `z.infer` types. */ - name: StringName; + infer: { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}ZodType' + */ + name: StringName; + }; }; }; - }; - /** - * Configuration for response-specific Zod schemas. - * - * Controls generation of Zod schemas for response bodies, error responses, - * and status codes. - */ - responses: { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case: StringCase; /** - * Whether to generate Zod schemas for response definitions. + * Should the exports from the generated files be re-exported in the index + * barrel file? * - * @default true + * @default false */ - enabled: boolean; + exportFromIndex: boolean; /** - * Custom naming pattern for generated schema names. The name variable is - * obtained from the operation name. + * Enable Zod metadata support? It's often useful to associate a schema with + * some additional metadata for documentation, code generation, AI + * structured outputs, form validation, and other purposes. * - * @default 'z{{name}}Response' + * @default false */ - name: StringName; + metadata: boolean; /** - * Configuration for TypeScript type generation from Zod schemas. + * Configuration for request-specific Zod schemas. * - * Controls generation of TypeScript types based on the generated Zod schemas. + * Controls generation of Zod schemas for request bodies, query parameters, path + * parameters, and headers. */ - types: { + requests: { /** - * Configuration for `z.infer` types. + * The casing convention to use for generated names. + * + * @default 'camelCase' */ - infer: { - /** - * The casing convention to use for generated type names. - * - * @default 'PascalCase' - */ - case: StringCase; - /** - * Whether to generate TypeScript types from Zod schemas. - * - * @default true - */ - enabled: boolean; + case: StringCase; + /** + * Whether to generate Zod schemas for request definitions. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable is + * obtained from the operation name. + * + * @default 'z{{name}}Data' + */ + name: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. + * + * Controls generation of TypeScript types based on the generated Zod schemas. + */ + types: { /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}ResponseZodType' + * Configuration for `z.infer` types. */ - name: StringName; + infer: { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}DataZodType' + */ + name: StringName; + }; }; }; - }; - /** - * Configuration for TypeScript type generation from Zod schemas. - * - * Controls generation of TypeScript types based on the generated Zod schemas. - */ - types: { /** - * Configuration for `z.infer` types. + * Configuration for response-specific Zod schemas. + * + * Controls generation of Zod schemas for response bodies, error responses, + * and status codes. */ - infer: { + responses: { /** - * The casing convention to use for generated type names. + * The casing convention to use for generated names. * - * @default 'PascalCase' + * @default 'camelCase' */ case: StringCase; /** - * Whether to generate TypeScript types from Zod schemas. + * Whether to generate Zod schemas for response definitions. * * @default true */ enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable is + * obtained from the operation name. + * + * @default 'z{{name}}Response' + */ + name: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. + * + * Controls generation of TypeScript types based on the generated Zod schemas. + */ + types: { + /** + * Configuration for `z.infer` types. + */ + infer: { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}ResponseZodType' + */ + name: StringName; + }; + }; }; - }; - /** - * Configuration for webhook-specific Zod schemas. - * - * Controls generation of Zod schemas for webhook payloads. - */ - webhooks: { - /** - * The casing convention to use for generated names. - * - * @default 'camelCase' - */ - case: StringCase; - /** - * Whether to generate Zod schemas for webhook definitions. - * - * @default true - */ - enabled: boolean; - /** - * Custom naming pattern for generated schema names. The name variable is - * is obtained from the webhook key. - * - * @default 'z{{name}}WebhookRequest' - */ - name: StringName; /** * Configuration for TypeScript type generation from Zod schemas. * @@ -736,16 +677,65 @@ export type Config = Plugin.Name<'zod'> & { * @default true */ enabled: boolean; + }; + }; + /** + * Configuration for webhook-specific Zod schemas. + * + * Controls generation of Zod schemas for webhook payloads. + */ + webhooks: { + /** + * The casing convention to use for generated names. + * + * @default 'camelCase' + */ + case: StringCase; + /** + * Whether to generate Zod schemas for webhook definitions. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated schema names. The name variable is + * is obtained from the webhook key. + * + * @default 'z{{name}}WebhookRequest' + */ + name: StringName; + /** + * Configuration for TypeScript type generation from Zod schemas. + * + * Controls generation of TypeScript types based on the generated Zod schemas. + */ + types: { /** - * Custom naming pattern for generated type names. The name variable is - * obtained from the Zod schema name. - * - * @default '{{name}}WebhookRequestZodType' + * Configuration for `z.infer` types. */ - name: StringName; + infer: { + /** + * The casing convention to use for generated type names. + * + * @default 'PascalCase' + */ + case: StringCase; + /** + * Whether to generate TypeScript types from Zod schemas. + * + * @default true + */ + enabled: boolean; + /** + * Custom naming pattern for generated type names. The name variable is + * obtained from the Zod schema name. + * + * @default '{{name}}WebhookRequestZodType' + */ + name: StringName; + }; }; }; }; -}; 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 a54a7e903..1562be1db 100644 --- a/packages/openapi-ts/src/plugins/zod/v3/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/v3/plugin.ts @@ -1,6 +1,5 @@ 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'; @@ -23,8 +22,10 @@ const arrayTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'array'>; state: State; -}): ts.CallExpression => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( +}): Omit & { + anyType?: string; +} => { + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -34,6 +35,7 @@ const arrayTypeToZodSchema = ({ }); let arrayExpression: ts.CallExpression | undefined; + let hasCircularReference = false; if (!schema.items) { arrayExpression = tsc.callExpression({ @@ -51,14 +53,17 @@ const arrayTypeToZodSchema = ({ schema = deduplicateSchema({ schema }); // at least one item is guaranteed - const itemExpressions = schema.items!.map( - (item) => - schemaToZodSchema({ - plugin, - schema: item, - state, - }).expression, - ); + const itemExpressions = schema.items!.map((item) => { + const zodSchema = schemaToZodSchema({ + plugin, + schema: item, + state, + }); + if (zodSchema.hasCircularReference) { + hasCircularReference = true; + } + return zodSchema.expression; + }); if (itemExpressions.length === 1) { arrayExpression = tsc.callExpression({ @@ -125,7 +130,10 @@ const arrayTypeToZodSchema = ({ } } - return arrayExpression; + return { + expression: arrayExpression, + hasCircularReference, + }; }; const booleanTypeToZodSchema = ({ @@ -135,7 +143,7 @@ const booleanTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'boolean'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -166,7 +174,7 @@ const enumTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'enum'>; }): ts.CallExpression => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -227,7 +235,7 @@ const neverTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'never'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const expression = tsc.callExpression({ @@ -245,7 +253,7 @@ const nullTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'null'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const expression = tsc.callExpression({ @@ -289,7 +297,7 @@ const numberTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'integer' | 'number'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -382,14 +390,15 @@ const objectTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'object'>; state: State; -}): { - anyType: string; - expression: ts.CallExpression; +}): Omit & { + anyType?: string; } => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); + let hasCircularReference = false; + // TODO: parser - handle constants const properties: Array = []; @@ -404,7 +413,11 @@ const objectTypeToZodSchema = ({ plugin, schema: property, state, - }).expression; + }); + + if (propertyExpression.hasCircularReference) { + hasCircularReference = true; + } numberRegExp.lastIndex = 0; let propertyName; @@ -427,7 +440,7 @@ const objectTypeToZodSchema = ({ } properties.push( tsc.propertyAssignment({ - initializer: propertyExpression, + initializer: propertyExpression.expression, name: propertyName, }), ); @@ -441,17 +454,18 @@ const objectTypeToZodSchema = ({ plugin, schema: schema.additionalProperties, state, - }).expression; + }); const expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: zSymbol.placeholder, name: identifiers.record, }), - parameters: [zodSchema], + parameters: [zodSchema.expression], }); return { anyType: 'AnyZodObject', expression, + hasCircularReference: zodSchema.hasCircularReference, }; } @@ -465,6 +479,7 @@ const objectTypeToZodSchema = ({ return { anyType: 'AnyZodObject', expression, + hasCircularReference, }; }; @@ -475,7 +490,7 @@ const stringTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'string'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -627,11 +642,15 @@ const tupleTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'tuple'>; state: State; -}) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( +}): Omit & { + anyType?: string; +} => { + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); + let hasCircularReference = false; + if (schema.const && Array.isArray(schema.const)) { const tupleElements = schema.const.map((value) => tsc.callExpression({ @@ -653,19 +672,24 @@ const tupleTypeToZodSchema = ({ }), ], }); - return expression; + return { + expression, + hasCircularReference, + }; } const tupleElements: Array = []; for (const item of schema.items ?? []) { - tupleElements.push( - schemaToZodSchema({ - plugin, - schema: item, - state, - }).expression, - ); + const zodSchema = schemaToZodSchema({ + plugin, + schema: item, + state, + }); + if (zodSchema.hasCircularReference) { + hasCircularReference = true; + } + tupleElements.push(zodSchema.expression); } const expression = tsc.callExpression({ @@ -679,7 +703,10 @@ const tupleTypeToZodSchema = ({ }), ], }); - return expression; + return { + expression, + hasCircularReference, + }; }; const undefinedTypeToZodSchema = ({ @@ -688,7 +715,7 @@ const undefinedTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'undefined'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const expression = tsc.callExpression({ @@ -706,7 +733,7 @@ const unknownTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'unknown'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const expression = tsc.callExpression({ @@ -724,7 +751,7 @@ const voidTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: SchemaWithType<'void'>; }) => { - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); const expression = tsc.callExpression({ @@ -744,19 +771,16 @@ const schemaTypeToZodSchema = ({ plugin: ZodPlugin['Instance']; schema: IR.SchemaObject; state: State; -}): { +}): Omit & { anyType?: string; - expression: ts.Expression; } => { switch (schema.type as Required['type']) { case 'array': - return { - expression: arrayTypeToZodSchema({ - plugin, - schema: schema as SchemaWithType<'array'>, - state, - }), - }; + return arrayTypeToZodSchema({ + plugin, + schema: schema as SchemaWithType<'array'>, + state, + }); case 'boolean': return { expression: booleanTypeToZodSchema({ @@ -807,13 +831,11 @@ const schemaTypeToZodSchema = ({ }), }; case 'tuple': - return { - expression: tupleTypeToZodSchema({ - plugin, - schema: schema as SchemaWithType<'tuple'>, - state, - }), - }; + return tupleTypeToZodSchema({ + plugin, + schema: schema as SchemaWithType<'tuple'>, + state, + }); case 'undefined': return { expression: undefinedTypeToZodSchema({ @@ -854,11 +876,9 @@ const schemaToZodSchema = ({ schema: IR.SchemaObject; state: State; }): ZodSchema => { - const f = plugin.gen.ensureFile(plugin.output); - let zodSchema: Partial = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -870,11 +890,11 @@ const schemaToZodSchema = ({ state.currentReferenceTracker.push(schema.$ref); const selector = plugin.api.getSelector('ref', schema.$ref); - let symbol = plugin.gen.selectSymbolFirst(selector); + let symbol = plugin.getSymbol(selector); if (isCircularReference) { if (!symbol) { - symbol = f.ensureSymbol({ selector }); + symbol = plugin.referenceSymbol(selector); } zodSchema.expression = tsc.callExpression({ @@ -892,23 +912,28 @@ const schemaToZodSchema = ({ }), ], }); - state.hasCircularReference = true; - } 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 - const ref = plugin.context.resolveIrRef(schema.$ref); - handleComponent({ - id: schema.$ref, - plugin, - schema: ref, - state, - }); - } + zodSchema.hasCircularReference = schema.circular; + } 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 + const ref = plugin.context.resolveIrRef(schema.$ref); + handleComponent({ + id: schema.$ref, + plugin, + schema: ref, + state: { + ...state, + currentReferenceTracker: [schema.$ref], + }, + }); + } else { + zodSchema.hasCircularReference = schema.circular; + } - if (!isCircularReference) { - const symbol = plugin.gen.selectSymbolFirstOrThrow(selector); - zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); + const refSymbol = plugin.referenceSymbol(selector); + zodSchema.expression = tsc.identifier({ text: refSymbol.placeholder }); } state.circularReferenceTracker.pop(); @@ -916,6 +941,7 @@ const schemaToZodSchema = ({ } else if (schema.type) { const zSchema = schemaTypeToZodSchema({ plugin, schema, state }); zodSchema.expression = zSchema.expression; + zodSchema.hasCircularReference = zSchema.hasCircularReference; zodSchema.typeName = zSchema.anyType; if (plugin.config.metadata && schema.description) { @@ -931,14 +957,17 @@ const schemaToZodSchema = ({ schema = deduplicateSchema({ schema }); if (schema.items) { - const itemTypes = schema.items.map( - (item) => - schemaToZodSchema({ - plugin, - schema: item, - state, - }).expression, - ); + const itemTypes = schema.items.map((item) => { + const zSchema = schemaToZodSchema({ + plugin, + schema: item, + state, + }); + if (zSchema.hasCircularReference) { + zodSchema.hasCircularReference = true; + } + return zSchema.expression; + }); if (schema.logicalOperator === 'and') { const firstSchema = schema.items[0]!; @@ -994,6 +1023,7 @@ const schemaToZodSchema = ({ state, }); zodSchema.expression = zSchema.expression; + zodSchema.hasCircularReference = zSchema.hasCircularReference; zodSchema.typeName = zSchema.anyType; } @@ -1034,11 +1064,11 @@ const schemaToZodSchema = ({ } } - if (state.hasCircularReference) { + if (zodSchema.hasCircularReference) { if (!zodSchema.typeName) { zodSchema.typeName = 'ZodTypeAny'; } - } else { + } else if (zodSchema.typeName) { zodSchema.typeName = undefined; } @@ -1065,21 +1095,25 @@ const handleComponent = ({ } const selector = plugin.api.getSelector('ref', id); - let symbol = plugin.gen.selectSymbolFirst(selector); - if (symbol && !symbol.headless) return; + let symbol = plugin.getSymbol(selector); + if (symbol) return; const zodSchema = schemaToZodSchema({ plugin, schema, state }); - const f = plugin.gen.ensureFile(plugin.output); const baseName = refToName(id); - symbol = f.ensureSymbol({ selector }); - symbol = symbol.update({ + symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.definitions, name: baseName, }), + selector, }); const typeInferSymbol = plugin.config.definitions.types.infer.enabled - ? f.addSymbol({ + ? plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.definitions.types.infer, name: baseName, @@ -1097,23 +1131,11 @@ const handleComponent = ({ }; export const handlerV3: ZodPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - - const zSymbol = f.ensureSymbol({ + plugin.registerSymbol({ + external: getZodModule({ plugin }), name: 'z', selector: plugin.api.getSelector('import', 'zod'), }); - f.addImport({ - aliases: { - [zSymbol.name]: zSymbol.placeholder, - }, - from: getZodModule({ plugin }), - names: [zSymbol.name], - }); plugin.forEach( 'operation', @@ -1175,9 +1197,4 @@ export const handlerV3: ZodPlugin['Handler'] = ({ 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/zod/v4/plugin.ts b/packages/openapi-ts/src/plugins/zod/v4/plugin.ts index e4f28b3e3..e6c89a417 100644 --- a/packages/openapi-ts/src/plugins/zod/v4/plugin.ts +++ b/packages/openapi-ts/src/plugins/zod/v4/plugin.ts @@ -1,6 +1,5 @@ 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'; @@ -26,7 +25,7 @@ const arrayTypeToZodSchema = ({ }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -140,7 +139,7 @@ const booleanTypeToZodSchema = ({ }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -199,7 +198,7 @@ const enumTypeToZodSchema = ({ }); } - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -236,7 +235,7 @@ const neverTypeToZodSchema = ({ schema: SchemaWithType<'never'>; }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); result.expression = tsc.callExpression({ @@ -255,7 +254,7 @@ const nullTypeToZodSchema = ({ schema: SchemaWithType<'null'>; }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); result.expression = tsc.callExpression({ @@ -303,7 +302,7 @@ const numberTypeToZodSchema = ({ const isBigInt = schema.type === 'integer' && schema.format === 'int64'; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -403,7 +402,7 @@ const objectTypeToZodSchema = ({ const required = schema.required ?? []; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -537,7 +536,7 @@ const stringTypeToZodSchema = ({ }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -708,7 +707,7 @@ const tupleTypeToZodSchema = ({ }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -773,7 +772,7 @@ const undefinedTypeToZodSchema = ({ schema: SchemaWithType<'undefined'>; }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); result.expression = tsc.callExpression({ @@ -792,7 +791,7 @@ const unknownTypeToZodSchema = ({ schema: SchemaWithType<'unknown'>; }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); result.expression = tsc.callExpression({ @@ -811,7 +810,7 @@ const voidTypeToZodSchema = ({ schema: SchemaWithType<'void'>; }): Omit => { const result: Partial> = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); result.expression = tsc.callExpression({ @@ -916,11 +915,9 @@ const schemaToZodSchema = ({ schema: IR.SchemaObject; state: State; }): ZodSchema => { - const f = plugin.gen.ensureFile(plugin.output); - let zodSchema: Partial = {}; - const zSymbol = plugin.gen.selectSymbolFirstOrThrow( + const zSymbol = plugin.referenceSymbol( plugin.api.getSelector('import', 'zod'), ); @@ -933,11 +930,11 @@ const schemaToZodSchema = ({ state.currentReferenceTracker.push(schema.$ref); const selector = plugin.api.getSelector('ref', schema.$ref); - let symbol = plugin.gen.selectSymbolFirst(selector); + let symbol = plugin.getSymbol(selector); if (isCircularReference) { if (!symbol) { - symbol = f.ensureSymbol({ selector }); + symbol = plugin.referenceSymbol(selector); } if (isSelfReference) { @@ -960,23 +957,25 @@ const schemaToZodSchema = ({ } else { zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); } - zodSchema.hasCircularReference = true; - } 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 - const ref = plugin.context.resolveIrRef(schema.$ref); - handleComponent({ - id: schema.$ref, - plugin, - schema: ref, - state, - }); - } + zodSchema.hasCircularReference = schema.circular; + } 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 + const ref = plugin.context.resolveIrRef(schema.$ref); + handleComponent({ + id: schema.$ref, + plugin, + schema: ref, + state, + }); + } else { + zodSchema.hasCircularReference = schema.circular; + } - if (!isCircularReference) { - const symbol = plugin.gen.selectSymbolFirstOrThrow(selector); - zodSchema.expression = tsc.identifier({ text: symbol.placeholder }); + const refSymbol = plugin.referenceSymbol(selector); + zodSchema.expression = tsc.identifier({ text: refSymbol.placeholder }); } state.circularReferenceTracker.pop(); @@ -1012,13 +1011,12 @@ const schemaToZodSchema = ({ schema = deduplicateSchema({ schema }); if (schema.items) { - const itemTypes = schema.items.map( - (item) => - schemaToZodSchema({ - plugin, - schema: item, - state, - }).expression, + const itemSchemas = schema.items.map((item) => + schemaToZodSchema({ + plugin, + schema: item, + state, + }), ); if (schema.logicalOperator === 'and') { @@ -1035,17 +1033,35 @@ const schemaToZodSchema = ({ expression: zSymbol.placeholder, name: identifiers.intersection, }), - parameters: itemTypes, + parameters: itemSchemas.map((schema) => schema.expression), }); } else { - zodSchema.expression = itemTypes[0]; - itemTypes.slice(1).forEach((item) => { + zodSchema.expression = itemSchemas[0]!.expression; + itemSchemas.slice(1).forEach((schema) => { zodSchema.expression = tsc.callExpression({ functionName: tsc.propertyAccessExpression({ expression: zodSchema.expression!, name: identifiers.and, }), - parameters: [item], + parameters: [ + schema.hasCircularReference + ? tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: zSymbol.placeholder, + name: identifiers.lazy, + }), + parameters: [ + tsc.arrowFunction({ + statements: [ + tsc.returnStatement({ + expression: schema.expression, + }), + ], + }), + ], + }) + : schema.expression, + ], }); }); } @@ -1057,7 +1073,7 @@ const schemaToZodSchema = ({ }), parameters: [ tsc.arrayLiteralExpression({ - elements: itemTypes, + elements: itemSchemas.map((schema) => schema.expression), }), ], }); @@ -1138,21 +1154,25 @@ const handleComponent = ({ }; const selector = plugin.api.getSelector('ref', id); - let symbol = plugin.gen.selectSymbolFirst(selector); - if (symbol && !symbol.headless) return; + let symbol = plugin.getSymbol(selector); + if (symbol && !plugin.getSymbolValue(symbol)) return; const zodSchema = schemaToZodSchema({ plugin, schema, state }); - const f = plugin.gen.ensureFile(plugin.output); const baseName = refToName(id); - symbol = f.ensureSymbol({ selector }); - symbol = symbol.update({ + symbol = plugin.registerSymbol({ + exported: true, name: buildName({ config: plugin.config.definitions, name: baseName, }), + selector, }); const typeInferSymbol = plugin.config.definitions.types.infer.enabled - ? f.addSymbol({ + ? plugin.registerSymbol({ + exported: true, + meta: { + kind: 'type', + }, name: buildName({ config: plugin.config.definitions.types.infer, name: baseName, @@ -1170,23 +1190,11 @@ const handleComponent = ({ }; export const handlerV4: ZodPlugin['Handler'] = ({ plugin }) => { - const f = plugin.gen.createFile(plugin.output, { - extension: '.ts', - path: '{{path}}.gen', - renderer: new TypeScriptRenderer(), - }); - - const zSymbol = f.ensureSymbol({ + plugin.registerSymbol({ + external: getZodModule({ plugin }), name: 'z', selector: plugin.api.getSelector('import', 'zod'), }); - f.addImport({ - aliases: { - [zSymbol.name]: zSymbol.placeholder, - }, - from: getZodModule({ plugin }), - names: [zSymbol.name], - }); plugin.forEach( 'operation', @@ -1248,9 +1256,4 @@ export const handlerV4: ZodPlugin['Handler'] = ({ 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/tsc/module.ts b/packages/openapi-ts/src/tsc/module.ts index a71d81a6e..0312b2124 100644 --- a/packages/openapi-ts/src/tsc/module.ts +++ b/packages/openapi-ts/src/tsc/module.ts @@ -192,12 +192,12 @@ export const createNamedImportDeclarations = ({ const hasNonTypeImport = importedTypes.some( (item) => typeof item !== 'object' || !item.asType, ); - let namespaceImport: ImportExportItemObject | undefined; + let namespaceBinding: ImportExportItemObject | undefined; const elements: Array = []; importedTypes.forEach((name) => { const item = typeof name === 'string' ? { name } : name; if (item.name === '*' && item.alias) { - namespaceImport = item; + namespaceBinding = item; } else { elements.push( ots.import({ @@ -208,9 +208,9 @@ export const createNamedImportDeclarations = ({ ); } }); - const namedBindings = namespaceImport + const namedBindings = namespaceBinding ? ts.factory.createNamespaceImport( - createIdentifier({ text: namespaceImport.alias! }), + createIdentifier({ text: namespaceBinding.alias! }), ) : ts.factory.createNamedImports(elements); const importClause = ts.factory.createImportClause( diff --git a/packages/openapi-ts/src/types/config.d.ts b/packages/openapi-ts/src/types/config.d.ts index a762bc8c3..ad1b4e2b4 100644 --- a/packages/openapi-ts/src/types/config.d.ts +++ b/packages/openapi-ts/src/types/config.d.ts @@ -2,7 +2,7 @@ import type { PluginConfigMap } from '../plugins/config'; import type { Plugin, PluginNames } from '../plugins/types'; import type { Input, Watch } from './input'; import type { Logs } from './logs'; -import type { Output } from './output'; +import type { Output, UserOutput } from './output'; import type { Parser, ResolvedParser } from './parser'; export interface UserConfig { @@ -51,9 +51,9 @@ export interface UserConfig { */ logs?: string | Logs; /** - * The relative location of the output folder. + * Path to the output folder. */ - output: string | Output; + output: string | UserOutput; /** * Customize how the input is parsed and transformed before it's passed to * plugins. @@ -143,11 +143,9 @@ export type Config = Omit< > & Pick & { input: Omit & - Pick, 'path'> & { - watch: Extract['watch']>, object>; - }; - logs: Extract, object>; - output: Extract; + Pick, 'path'> & { watch: Watch }; + logs: Logs; + output: Output; /** * Customize how the input is parsed and transformed before it's passed to * plugins. diff --git a/packages/openapi-ts/src/types/output.d.ts b/packages/openapi-ts/src/types/output.d.ts index 6b85941af..94b483bb0 100644 --- a/packages/openapi-ts/src/types/output.d.ts +++ b/packages/openapi-ts/src/types/output.d.ts @@ -1,10 +1,10 @@ -import type { StringCase } from './case'; +import type { StringCase, StringName } from './case'; export type Formatters = 'biome' | 'prettier'; export type Linters = 'biome' | 'eslint' | 'oxlint'; -export type Output = { +export type UserOutput = { /** * Defines casing of the output fields. By default, we preserve `input` * values as data transforms incur a performance penalty at runtime. @@ -21,6 +21,41 @@ export type Output = { * @default true */ clean?: boolean; + /** + * Optional function to transform file names before they are used. + * + * @param name The original file name. + * @returns The transformed file name. + * @default '{{name}}' + */ + fileName?: + | StringName + | { + /** + * The casing convention to use for generated file names. + * + * @default 'preserve' + */ + case?: StringCase; + /** + * Custom naming pattern for generated file names. + * + * @default '{{name}}' + */ + name?: StringName; + /** + * Suffix to append to file names (before the extension). For example, + * with a suffix of `.gen`, `example.ts` becomes `example.gen.ts`. + * + * @default '.gen' + * @example + * // Given a suffix of `.gen` + * 'index.ts' -> 'index.ts' (index files are not renamed) + * 'user.ts' -> 'user.gen.ts' + * 'order.gen.ts' -> 'order.gen.ts' (files already containing the suffix are not renamed) + */ + suffix?: string | null; + }; /** * Process output folder with formatter? * @@ -42,7 +77,7 @@ export type Output = { */ lint?: Linters | false; /** - * The relative location of the output folder + * The absolute path to the output folder. */ path: string; /** @@ -50,6 +85,92 @@ export type Output = { * generate the output. If a path to tsconfig file is not provided, we * attempt to find one starting from the location of the * `@hey-api/openapi-ts` configuration file and traversing up. + * + * @default '' */ tsConfigPath?: 'off' | (string & {}); }; + +export type Output = { + /** + * Defines casing of the output fields. By default, we preserve `input` + * values as data transforms incur a performance penalty at runtime. + * + * @default undefined + */ + case?: Exclude; + /** + * Clean the `output` folder on every run? If disabled, this folder may + * be used to store additional files. The default option is `true` to + * reduce the risk of keeping outdated files around when configuration, + * input, or package version changes. + * + * @default true + */ + clean: boolean; + /** + * Optional function to transform file names before they are used. + * + * @param name The original file name. + * @returns The transformed file name. + */ + fileName: { + /** + * The casing convention to use for generated file names. + * + * @default 'preserve' + */ + case: StringCase; + /** + * Custom naming pattern for generated file names. + * + * @default '{{name}}' + */ + name: StringName; + /** + * Suffix to append to file names (before the extension). For example, + * with a suffix of `.gen`, `example.ts` becomes `example.gen.ts`. + * + * @default '.gen' + * @example + * // Given a suffix of `.gen` + * 'index.ts' -> 'index.ts' (index files are not renamed) + * 'user.ts' -> 'user.gen.ts' + * 'order.gen.ts' -> 'order.gen.ts' (files already containing the suffix are not renamed) + */ + suffix: string | null; + }; + /** + * Process output folder with formatter? + * + * @default false + */ + format: Formatters | false; + /** + * Should the exports from plugin files be re-exported in the index + * barrel file? By default, this is enabled and only default plugins + * are re-exported. + * + * @default true + */ + indexFile: boolean; + /** + * Process output folder with linter? + * + * @default false + */ + lint: Linters | false; + /** + * The absolute path to the output folder. + */ + path: string; + /** + * Relative or absolute path to the tsconfig file we should use to + * generate the output. If a path to tsconfig file is not provided, we + * attempt to find one starting from the location of the + * `@hey-api/openapi-ts` configuration file and traversing up. + * + * @default '' + */ + tsConfigPath: 'off' | (string & {}); +}; diff --git a/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts b/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts index 6150639e4..2c683ed43 100644 --- a/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts +++ b/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts @@ -30,8 +30,17 @@ describe('registerHandlebarHelpers', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, format: 'prettier', + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, @@ -146,8 +155,17 @@ describe('registerHandlebarTemplates', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, format: 'prettier', + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, diff --git a/packages/openapi-ts/src/utils/__tests__/parse.test.ts b/packages/openapi-ts/src/utils/__tests__/parse.test.ts index 45bea2a94..e0cec7036 100644 --- a/packages/openapi-ts/src/utils/__tests__/parse.test.ts +++ b/packages/openapi-ts/src/utils/__tests__/parse.test.ts @@ -24,7 +24,17 @@ describe('operationNameFn', () => { path: process.cwd(), }, output: { + clean: false, + fileName: { + case: 'preserve', + name: '{{name}}', + suffix: '.gen', + }, + format: false, + indexFile: true, + lint: false, path: '', + tsConfigPath: '', }, parser: { hooks: {}, -- 2.51.2 From e1ede9cabf52b5bbcb9195570deff58db8f43dbb Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 22 Sep 2025 04:56:51 +0800 Subject: [PATCH 19/19] docs: add changelog --- .changeset/beige-rocks-remain.md | 5 ++ .changeset/eleven-beans-sort.md | 9 ++ .changeset/healthy-experts-grow.md | 33 +++++++ .changeset/selfish-hornets-beg.md | 5 ++ .changeset/two-buses-dance.md | 15 ++++ docs/.vitepress/config/en.ts | 2 +- docs/openapi-ts/configuration/output.md | 72 ++++++++++++++++ docs/openapi-ts/configuration/parser.md | 86 +++++++++++++++---- docs/openapi-ts/get-started.md | 2 +- docs/openapi-ts/migrating.md | 16 ++++ docs/package.json | 2 +- package.json | 2 +- .../main/test/openapi-ts.config.ts | 5 +- packages/openapi-ts/README.md | 2 +- 14 files changed, 233 insertions(+), 23 deletions(-) create mode 100644 .changeset/beige-rocks-remain.md create mode 100644 .changeset/eleven-beans-sort.md create mode 100644 .changeset/healthy-experts-grow.md create mode 100644 .changeset/selfish-hornets-beg.md create mode 100644 .changeset/two-buses-dance.md diff --git a/.changeset/beige-rocks-remain.md b/.changeset/beige-rocks-remain.md new file mode 100644 index 000000000..bda31391a --- /dev/null +++ b/.changeset/beige-rocks-remain.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(plugin): every plugin extends Plugin.Hooks interface diff --git a/.changeset/eleven-beans-sort.md b/.changeset/eleven-beans-sort.md new file mode 100644 index 000000000..8851e045b --- /dev/null +++ b/.changeset/eleven-beans-sort.md @@ -0,0 +1,9 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(renderer): group and sort imported modules + +### TypeScript renderer + +We ship a dedicated TypeScript renderer for `.ts` files. This release improves the renderer's ability to group and sort imported modules, resulting in a more polished output. diff --git a/.changeset/healthy-experts-grow.md b/.changeset/healthy-experts-grow.md new file mode 100644 index 000000000..75f73efa4 --- /dev/null +++ b/.changeset/healthy-experts-grow.md @@ -0,0 +1,33 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(config): add `output.fileName` option + +## File Name + +You can customize the naming and casing pattern for files using the `fileName` option. + +```js +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: { + fileName: '{{name}}', + path: 'src/client', + }, +}; +``` + +By default, we append every file name with a `.gen` suffix to highlight it's automatically generated. You can customize or disable this suffix using the `fileName.suffix` option. + +```js +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: { + fileName: { + suffix: '.gen', + }, + path: 'src/client', + }, +}; +``` diff --git a/.changeset/selfish-hornets-beg.md b/.changeset/selfish-hornets-beg.md new file mode 100644 index 000000000..f42cc58b6 --- /dev/null +++ b/.changeset/selfish-hornets-beg.md @@ -0,0 +1,5 @@ +--- +'@hey-api/codegen-core': minor +--- + +feat: Symbol API diff --git a/.changeset/two-buses-dance.md b/.changeset/two-buses-dance.md new file mode 100644 index 000000000..8a2e300a6 --- /dev/null +++ b/.changeset/two-buses-dance.md @@ -0,0 +1,15 @@ +--- +'@hey-api/openapi-ts': minor +--- + +feat: Symbol API + +### Symbol API + +This release improves the Symbol API, which adds the capability to place symbols in arbitrary files. We preserved the previous output structure for all plugins except Angular. + +You can preserve the previous Angular output by writing your own [placement function](https://heyapi.dev/openapi-ts/configuration/parser#hooks-symbols). + +### Removed `output` plugin option + +Due to the Symbol API release, this option has been removed from the Plugin API. diff --git a/docs/.vitepress/config/en.ts b/docs/.vitepress/config/en.ts index 56be1a690..d3c9213ac 100644 --- a/docs/.vitepress/config/en.ts +++ b/docs/.vitepress/config/en.ts @@ -258,7 +258,7 @@ export default defineConfig({ text: 'Custom', }, ], - text: 'Guides and Concepts', + text: 'Plugins', }, { items: [ diff --git a/docs/openapi-ts/configuration/output.md b/docs/openapi-ts/configuration/output.md index 660b12097..0abc493b1 100644 --- a/docs/openapi-ts/configuration/output.md +++ b/docs/openapi-ts/configuration/output.md @@ -34,6 +34,78 @@ export default { ::: +## File Name + +You can customize the naming and casing pattern for files using the `fileName` option. + +::: code-group + +```js [default] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: { + fileName: '{{name}}', // [!code ++] + path: 'src/client', + }, +}; +``` + +```js [snake_case] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: { + fileName: { + case: 'snake_case', // [!code ++] + }, + path: 'src/client', + }, +}; +``` + +::: + +By default, we append every file name with a `.gen` suffix to highlight it's automatically generated. You can customize or disable this suffix using the `fileName.suffix` option. + +::: code-group + +```js [default] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: { + fileName: { + suffix: '.gen', // [!code ++] + }, + path: 'src/client', + }, +}; +``` + +```js [off] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: { + fileName: { + suffix: null, // [!code ++] + }, + path: 'src/client', + }, +}; +``` + +```js [custom] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: { + fileName: { + suffix: '.generated', // [!code ++] + }, + path: 'src/client', + }, +}; +``` + +::: + ## Format To format your output folder contents, set `output.format` to a valid formatter. diff --git a/docs/openapi-ts/configuration/parser.md b/docs/openapi-ts/configuration/parser.md index d4cf7f3d4..a3684fcf5 100644 --- a/docs/openapi-ts/configuration/parser.md +++ b/docs/openapi-ts/configuration/parser.md @@ -460,7 +460,36 @@ export default { ## Hooks -Hooks affect runtime behavior but aren’t tied to any single plugin. They can be configured globally via `parser.hooks` or per plugin through the `~hooks` property. +Hooks affect runtime behavior but aren’t tied to any single plugin. They can be configured globally via `hooks` or per plugin through the `~hooks` property. + +::: code-group + +```js [parser] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: 'src/client', + parser: { + hooks: {}, // configure global hooks here // [!code ++] + }, +}; +``` + +```js [plugin] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: 'src/client', + plugins: [ + { + name: '@tanstack/react-query', + '~hooks': {}, // configure plugin hooks here // [!code ++] + }, + ], +}; +``` + +::: + +We always use the first hook that returns a value. If a hook returns no value, we fall back to less specific hooks until one does. ### Operations {#hooks-operations} @@ -478,12 +507,12 @@ By default, DELETE, PATCH, POST, and PUT operations are classified as `mutation` Imagine your API has a POST `/search` endpoint that accepts a large payload. By default, it's classified as a `mutation`, but in practice it behaves like a `query`, and your [state management](/openapi-ts/state-management) plugin should generate query hooks. -You can fix this by classifying the operation as `query` in a matcher. If a matcher returns no value, we fall back to less specific matchers until one does. +You can achieve this by classifying the operation as `query` in a matcher. ::: code-group -```js [parser] +```js [isQuery] export default { input: 'hey-api/backend', // sign up at app.heyapi.dev output: 'src/client', @@ -502,29 +531,56 @@ export default { ``` -```js [plugin] +```js [getKind] export default { input: 'hey-api/backend', // sign up at app.heyapi.dev output: 'src/client', - plugins: [ - { - name: '@tanstack/react-query', - '~hooks': { - operations: { - getKind: (op) => { - if (op.method === 'post' && op.path === '/search') { // [!code ++] - return ['query']; // [!code ++] - } // [!code ++] - }, + parser: { + hooks: { + operations: { + getKind: (op) => { + if (op.method === 'post' && op.path === '/search') { // [!code ++] + return ['query']; // [!code ++] + } // [!code ++] }, }, }, - ], + }, }; ``` ::: +### Symbols {#hooks-symbols} + +Each symbol can have a placement function deciding its output location. + +#### Example: Alphabetic sort + +While we work on a better example, let's imagine a world where it's desirable to place every symbol in a file named after its initial letter. For example, a function named `Foo` should end up in the file `f.ts`. + +You can achieve this by using the symbol's name. + + +```js [getKind] +export default { + input: 'hey-api/backend', // sign up at app.heyapi.dev + output: 'src/client', + parser: { + hooks: { + symbols: { + getFilePath: (symbol) => { + if (symbol.name) { // [!code ++] + return symbol.name[0]?.toLowerCase(); // [!code ++] + } // [!code ++] + }, + }, + }, + }, +}; +``` + + diff --git a/docs/openapi-ts/get-started.md b/docs/openapi-ts/get-started.md index 8c151a52b..e8c7e93ce 100644 --- a/docs/openapi-ts/get-started.md +++ b/docs/openapi-ts/get-started.md @@ -21,7 +21,7 @@ Launch demo - runs in CLI, Node.js 18+, or npx - works with OpenAPI 2.0, 3.0, and 3.1 -- customizable types and SDKs +- core plugins for types, SDKs, and schemas - clients for your runtime (Fetch API, Angular, Axios, Next.js, Nuxt, etc.) - plugin ecosystem to reduce third-party boilerplate - custom plugins and custom clients diff --git a/docs/openapi-ts/migrating.md b/docs/openapi-ts/migrating.md index 92075b289..d85eb5afd 100644 --- a/docs/openapi-ts/migrating.md +++ b/docs/openapi-ts/migrating.md @@ -7,6 +7,22 @@ description: Migrating to @hey-api/openapi-ts. While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features. This page lists changes that require updates to your code. If you run into a problem with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues). +## v0.84.0 + +### Symbol API + +This release improves the Symbol API, which adds the capability to place symbols in arbitrary files. We preserved the previous output structure for all plugins except Angular. + +You can preserve the previous Angular output by writing your own [placement function](/openapi-ts/configuration/parser#hooks-symbols). + +### TypeScript renderer + +We ship a dedicated TypeScript renderer for `.ts` files. This release improves the renderer's ability to group and sort imported modules, resulting in a more polished output. + +### Removed `output` plugin option + +Due to the Symbol API release, this option has been removed from the Plugin API. + ## v0.83.0 ### Symbol API diff --git a/docs/package.json b/docs/package.json index f27da54db..110041013 100644 --- a/docs/package.json +++ b/docs/package.json @@ -20,5 +20,5 @@ "vitepress-plugin-llms": "1.7.3", "vue": "3.5.13" }, - "packageManager": "pnpm@10.15.0" + "packageManager": "pnpm@10.17.0" } diff --git a/package.json b/package.json index 6cb3fc638..532c1e958 100644 --- a/package.json +++ b/package.json @@ -70,5 +70,5 @@ "typescript-eslint": "8.29.1", "vitest": "3.1.1" }, - "packageManager": "pnpm@10.15.1" + "packageManager": "pnpm@10.17.0" } 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 4d13c24f2..7f48b407e 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -76,7 +76,7 @@ export default defineConfig(() => { fileName: { // case: 'snake_case', // name: '{{name}}.renamed', - // suffix: '.meh', + suffix: '.meh', }, // format: 'prettier', // indexFile: false, @@ -124,10 +124,9 @@ export default defineConfig(() => { symbols: { // getFilePath: (symbol) => { // if (symbol.name) { - // return symbol.name[0]?.toLocaleLowerCase(); + // return symbol.name[0]?.toLowerCase(); // } // return; - // // noop // }, }, }, diff --git a/packages/openapi-ts/README.md b/packages/openapi-ts/README.md index cbbdfa756..67ba45e9c 100644 --- a/packages/openapi-ts/README.md +++ b/packages/openapi-ts/README.md @@ -33,7 +33,7 @@ - runs in CLI, Node.js 18+, or npx - works with OpenAPI 2.0, 3.0, and 3.1 -- customizable types and SDKs +- core plugins for types, SDKs, and schemas - clients for your runtime (Fetch API, Angular, Axios, Next.js, Nuxt, etc.) - plugin ecosystem to reduce third-party boilerplate - custom plugins and custom clients