diff --git a/.changeset/beige-rocks-remain.md b/.changeset/beige-rocks-remain.md new file mode 100644 index 0000000000..bda31391ae --- /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 0000000000..8851e045b5 --- /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 0000000000..75f73efa48 --- /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 0000000000..f42cc58b6b --- /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 0000000000..8a2e300a68 --- /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 56be1a690f..d3c9213ac6 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 660b120970..0abc493b16 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 d4cf7f3d49..a3684fcf51 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 8c151a52bf..e8c7e93ce0 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 92075b289a..d85eb5afd6 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 f27da54db3..1100410134 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 6cb3fc6380..532c1e958f 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/codegen-core/src/__tests__/bimap.test.ts b/packages/codegen-core/src/__tests__/bimap.test.ts new file mode 100644 index 0000000000..b28fe2665e --- /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 0000000000..7debb873e3 --- /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 0000000000..36a664ada2 --- /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 8ad3adb676..0000000000 --- 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 0000000000..a90011a233 --- /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 3d1e6d9e26..d7f2a70a66 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 efaf438a61..48559e13b4 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 0000000000..4d905797f0 --- /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 c2cc9ef8f7..93f21afb96 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 610d6b2f3e..c7b81aea3c 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 e0c0498348..2510411f9e 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 0000000000..84cc84b997 --- /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 0000000000..092b1220f9 --- /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 36d05a653d..0000000000 --- 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 0000000000..f0aca25210 --- /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 b4740b0d6d..6ba2f7b80e 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 be34377493..345a3daff3 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 e1486202b5..0000000000 --- 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 c8c6b869eb..7fa4a00d70 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 b966601d2d..cbdc584215 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 b60f1c779c..22d2c6ba79 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 0000000000..651d28c0cb --- /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 184c693168..608c07f9f6 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 bcb7e07572..0000000000 --- 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 0000000000..ef7ecfd042 --- /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 0000000000..a98987642b --- /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 e9029605a3..cd8f68111f 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 fc868ad331..7d4ddc8d7b 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 0339b6e31e..b43a5238d8 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 62bdb7f987..00338555a5 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 0339b6e31e..b43a5238d8 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 067709e9c1..4585c357e9 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 d0712e0976..0c52381d24 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 dc6943369b..01dd71cbd5 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 0339b6e31e..b43a5238d8 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 752a77a581..22744bba68 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 0339b6e31e..b43a5238d8 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 fb55304b4e..4d23f29179 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 0339b6e31e..b43a5238d8 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 8dcf013dd1..0ca18993d7 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 0339b6e31e..b43a5238d8 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 df988a03dd..3efeb697a2 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 0339b6e31e..b43a5238d8 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 a0cf12a01f..5c735bac3a 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 0339b6e31e..b43a5238d8 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 7352108dc2..c4db836023 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 0339b6e31e..b43a5238d8 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 cde22290fe..d29c33f61b 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 0339b6e31e..b43a5238d8 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 16ea572192..be7cbd0e5b 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 0339b6e31e..b43a5238d8 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 658609c2a2..bbcdebda61 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 0339b6e31e..b43a5238d8 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 e8450c4070..57e45fac7a 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 0339b6e31e..b43a5238d8 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 538bc4b3c6..3d87fcc64d 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 0339b6e31e..b43a5238d8 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 9452f2b9e1..6ec2488090 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 0339b6e31e..b43a5238d8 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 2f6988dd6d..ff23db4fcd 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 0339b6e31e..b43a5238d8 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 3d1e1fbe6f..3302d8733d 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 99b508c956..253cdc0ff4 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 7b434343a6..997ebc24bd 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 0000000000..f980e3995e --- /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 1f9271d48f..0000000000 --- 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 53da1170db..0000000000 --- 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 cdc6464740..503bea246b 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 df3ac474b9..0000000000 --- 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 e28017eaf1..7f92a6b239 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 cc646f13a5..c352c1047a 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 2d5985b319..91bd50dc5d 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 3c9d905697..3f503a59dd 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 e28017eaf1..7f92a6b239 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 cc646f13a5..c352c1047a 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 4ff334ff74..58f593d8a6 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 3c9d905697..3f503a59dd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 4cf0ca9c47..2d511cf078 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 28d798a000..9844839dee 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 7190dd07b7..778e50856f 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 cc646f13a5..c352c1047a 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 4140ac3769..f4f9f2b612 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 b0edf4e795..37a560625f 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 5c161731c5..1f8bf6602a 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 cc9dcf8412..ea991c983e 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 2b264a4ce1..b8aa017cdd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 9067c31ee3..e6ec9cb52e 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 cc9dcf8412..ea991c983e 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 2b264a4ce1..b8aa017cdd 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 a7f908ad21..db3956e796 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 54931798c8..6ab8910b76 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 e31c2880d8..a19022118c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 28d798a000..9844839dee 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 9b66b5118d..b4ca9d1c9a 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 01f8e2d247..7d91375f4c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 28d798a000..9844839dee 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 5edad337f0..7d18a46031 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 84d57fda43..e801ca3f6f 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 7426764683..e06f04f517 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 8d3bdd5146..f29ed5c751 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 cc71b7997e..2e9bb8e0bd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 28d798a000..9844839dee 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 4dfbf97a81..89d6c36e26 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 28d798a000..9844839dee 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 8f1ad7c352..19897d1de2 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 84d57fda43..e801ca3f6f 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 7426764683..e06f04f517 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 244f7d8d09..7124c7bda9 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 80cf0ec007..e28573f3a7 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 28d798a000..9844839dee 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 df3b287f42..36484b5ca0 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 28d798a000..9844839dee 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 88d9a436a8..26046c97ba 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 84d57fda43..e801ca3f6f 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 7426764683..e06f04f517 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 e3d114c97d..0b369e6393 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 392d846215..6bc30992cb 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 28d798a000..9844839dee 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 c8e3b0f3fc..2e10ae9efb 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 28d798a000..9844839dee 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 927760423d..84195d1ebc 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 84d57fda43..e801ca3f6f 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 7426764683..e06f04f517 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 70f5b99be5..381286d22f 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 98f162bebb..6649417560 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 28d798a000..9844839dee 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 cbbcb26a7b..8e51a85ecd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 28d798a000..9844839dee 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 bf63c8f5b9..352f9bd8b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 84d57fda43..e801ca3f6f 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 7426764683..e06f04f517 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 0eef4016fe..c775bdfe2a 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 b215924fa0..d93ccb7c08 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 b0edf4e795..37a560625f 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 463216f2d8..bb9cf3b212 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 28d798a000..9844839dee 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 b131cb6ce5..8451220765 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 0339b6e31e..b43a5238d8 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 b0edf4e795..37a560625f 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 e5bff5c843..a2ec6738e7 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 a31ef78658..34a73e0be0 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 abeb3e1f87..ce899130ea 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 47a6dbbcee..4d911cbe3b 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 6293e99d64..159ddeb7ac 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 47a6dbbcee..4d911cbe3b 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 5f3be6607c..452f08b23b 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 47a6dbbcee..4d911cbe3b 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 8e56592817..d5b1bcc1de 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 47a6dbbcee..4d911cbe3b 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 84e402e937..aadb5db4ac 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 0339b6e31e..b43a5238d8 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 7e1ba40072..c3fcf5dff4 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 85dba01eba..ca0a2a79ef 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 53f8b21772..fd7b9d4cce 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 0339b6e31e..b43a5238d8 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 43d939745b..b54728320a 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 9db142760b..127185a830 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 0339b6e31e..b43a5238d8 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 d90f5b3aff..2a149e8304 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 0339b6e31e..b43a5238d8 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 d67d3d123f..4452f8fca4 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 0339b6e31e..b43a5238d8 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 1097aeb996..d082071015 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 0339b6e31e..b43a5238d8 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 4ac0687620..22248bd725 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 0339b6e31e..b43a5238d8 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 6a8c31d0a6..d998d02b5c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 d0712e0976..0c52381d24 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 a1b0611747..5e6e1ffec9 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 0339b6e31e..b43a5238d8 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 54cfcc64e2..0dd627bfc0 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 0339b6e31e..b43a5238d8 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 a29cd8ba63..038783521d 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 0339b6e31e..b43a5238d8 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 ef766fce05..d30a3e9511 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 0339b6e31e..b43a5238d8 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 954c678b29..89b79fffee 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 0339b6e31e..b43a5238d8 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 492b157bfa..87f3a1faff 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 0339b6e31e..b43a5238d8 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 908d5cbec9..97bd27233b 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 f9331f0a1e..0d9a49b3f4 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 a2e7d5433b..71bb113048 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 0339b6e31e..b43a5238d8 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 3bd1045c3f..517394ec67 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 0339b6e31e..b43a5238d8 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 a3d6081eb6..902f48ad57 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 0339b6e31e..b43a5238d8 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 885b1c7d18..5fc5875d45 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 0339b6e31e..b43a5238d8 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 73005d2172..7637bb05f7 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 0339b6e31e..b43a5238d8 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 db360dbbd2..076177775a 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 0339b6e31e..b43a5238d8 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 5ae81db360..6e877c00f4 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 0339b6e31e..b43a5238d8 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 980626acc2..ba7939b4f6 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 0339b6e31e..b43a5238d8 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 c1d043ba00..93dd5188f2 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 0339b6e31e..b43a5238d8 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 ed1eac27af..59d8a10554 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 0339b6e31e..b43a5238d8 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 a0ada44fc3..14a3b53831 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 0339b6e31e..b43a5238d8 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 6c76ad8766..439b401702 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 0339b6e31e..b43a5238d8 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 a3452042d2..436e55f838 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 0339b6e31e..b43a5238d8 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 b4fdbac560..976eb7216b 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 0339b6e31e..b43a5238d8 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 30d55e299b..c34b8edc94 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 0339b6e31e..b43a5238d8 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 d8b9e50d18..7f0916345d 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 0339b6e31e..b43a5238d8 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 c25efe0136..72d21c8b5d 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 0339b6e31e..b43a5238d8 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 48930e9981..ae4406721b 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 0339b6e31e..b43a5238d8 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 c99c716425..7b43908d91 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 0339b6e31e..b43a5238d8 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 95af7e0f2b..a4169a3d5e 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 0339b6e31e..b43a5238d8 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 ece8dbc8d8..c668186a7b 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 0339b6e31e..b43a5238d8 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 7c6cf43ce7..7bbcad881d 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 0339b6e31e..b43a5238d8 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 0f113e6014..49d10ce0fe 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 0339b6e31e..b43a5238d8 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 29f6d3874b..bf1605beb9 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 0339b6e31e..b43a5238d8 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 2ab40752d9..8f041dff72 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 3e8c2dc317..3fc4764055 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 0959250192..51d54a06a3 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 3b84b928ca..fae694b9b2 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 0339b6e31e..b43a5238d8 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 c8043dbaaa..4c71cace9b 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 c968befbcc..8092866330 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 4639723fb3..62af858b94 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 c968befbcc..8092866330 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 7e5ae03572..d564215cf5 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 0000000000..c5e0605a82 --- /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 84312629c4..0000000000 --- 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 bd8a166a25..0000000000 --- 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 0000000000..14fa2efa12 --- /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 e7b3678caf..0000000000 --- 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 a6d4fdd5bf..0000000000 --- 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 e28017eaf1..7f92a6b239 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 cc646f13a5..c352c1047a 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 2d5985b319..91bd50dc5d 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 3c9d905697..3f503a59dd 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 e28017eaf1..7f92a6b239 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 cc646f13a5..c352c1047a 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 4ff334ff74..58f593d8a6 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 3c9d905697..3f503a59dd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 4cf0ca9c47..2d511cf078 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 4001df3e99..836288372b 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 7190dd07b7..778e50856f 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 cc646f13a5..c352c1047a 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 6d229fd5d5..c192301321 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 7fddaa46da..63b7de2ac4 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 5c161731c5..1f8bf6602a 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 cc9dcf8412..ea991c983e 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 ba800b837b..87d807f950 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 9067c31ee3..e6ec9cb52e 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 cc9dcf8412..ea991c983e 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 ba800b837b..87d807f950 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 21ae98a776..09a3a4b1ff 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 b73d450d02..68b3b8b10c 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 e31c2880d8..a19022118c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 127e25c29b..353fd0b405 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 01f8e2d247..7d91375f4c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 6850887fc8..75d351cb2b 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 d45c1ce282..6895e3c7ab 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 fda250e999..bd00301472 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 cc71b7997e..2e9bb8e0bd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 4dfbf97a81..89d6c36e26 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 ade1691a24..015d0c2412 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 d45c1ce282..6895e3c7ab 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 c4d0314518..0ecbef3818 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 80cf0ec007..e28573f3a7 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 df3b287f42..36484b5ca0 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 bddcb34e92..0ce0192c4f 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 d45c1ce282..6895e3c7ab 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 e150db91be..a2ba96f005 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 392d846215..6bc30992cb 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 c8e3b0f3fc..2e10ae9efb 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 822ebb27de..911c37db39 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 d45c1ce282..6895e3c7ab 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 e883dc5376..e468d7e86a 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 98f162bebb..6649417560 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 cbbcb26a7b..8e51a85ecd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 c86860577e..3b0e94261d 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 d45c1ce282..6895e3c7ab 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 c21b03b976..d9efc68660 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 7fddaa46da..63b7de2ac4 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 463216f2d8..bb9cf3b212 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 f7b237f6a1..0078ac95d2 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 0339b6e31e..b43a5238d8 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 7fddaa46da..63b7de2ac4 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 2b1dad28ca..5e0213cae0 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 7cd25c229a..41519aa51f 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 5f3be6607c..452f08b23b 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 579f645ec1..f0896eeeaa 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 8e56592817..d5b1bcc1de 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 579f645ec1..f0896eeeaa 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 8e56592817..d5b1bcc1de 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 579f645ec1..f0896eeeaa 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 8e56592817..d5b1bcc1de 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 579f645ec1..f0896eeeaa 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 53f8b21772..fd7b9d4cce 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 0339b6e31e..b43a5238d8 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 02482e56af..d7a0ac4610 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 9336baf5a1..36c9e46797 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 e2bd161643..f3fe6fe4c5 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 62f0dd462c..dad31f0d02 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 dfee230931..12991171f5 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 89be77eab1..fd57de924c 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 6c839b35db..57871fe36c 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 0339b6e31e..b43a5238d8 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 b507475fd4..28b3e9b1c3 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 0339b6e31e..b43a5238d8 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 d90f5b3aff..2a149e8304 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 0339b6e31e..b43a5238d8 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 31ed4dfc73..f2bd4bfe88 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 0339b6e31e..b43a5238d8 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 d67d3d123f..4452f8fca4 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 0339b6e31e..b43a5238d8 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 1097aeb996..d082071015 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 0339b6e31e..b43a5238d8 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 4ac0687620..22248bd725 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 0339b6e31e..b43a5238d8 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 6a8c31d0a6..d998d02b5c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 d0712e0976..0c52381d24 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 a1b0611747..5e6e1ffec9 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 0339b6e31e..b43a5238d8 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 54cfcc64e2..0dd627bfc0 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 0339b6e31e..b43a5238d8 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 a29cd8ba63..038783521d 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 0339b6e31e..b43a5238d8 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 ef766fce05..d30a3e9511 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 0339b6e31e..b43a5238d8 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 954c678b29..89b79fffee 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 0339b6e31e..b43a5238d8 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 0339b6e31e..b43a5238d8 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 9e134c9a8a..139e7bacc6 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 9ce1b2c404..37c40c5f18 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 0339b6e31e..b43a5238d8 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 e497b32cca..48d3700984 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 83b5f6181c..a4462c23b5 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 430815c638..c7a2005ffd 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 cea7f39ce6..5556b3a701 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 d265aed90e..5bbd28da60 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 83b5f6181c..a4462c23b5 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 0339b6e31e..b43a5238d8 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 e671e5b13e..c1b190d6e8 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 ccd37e81c8..cf95338106 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 d7073900a6..c5aadf7ee1 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 4c755476d7..28ad7b64bd 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 8b954d0127..b470364540 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 cea7f39ce6..5556b3a701 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 d3cddea8e8..83aa4d60ce 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 4c755476d7..28ad7b64bd 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 0339b6e31e..b43a5238d8 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 e671e5b13e..c1b190d6e8 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 ccd37e81c8..cf95338106 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 d7073900a6..c5aadf7ee1 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 4c755476d7..28ad7b64bd 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 8b954d0127..b470364540 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 cea7f39ce6..5556b3a701 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 d3cddea8e8..83aa4d60ce 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 4c755476d7..28ad7b64bd 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 0339b6e31e..b43a5238d8 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 0339b6e31e..b43a5238d8 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 9e134c9a8a..139e7bacc6 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 9ce1b2c404..37c40c5f18 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 0339b6e31e..b43a5238d8 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 10e25d8717..ef6579a749 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 10e25d8717..ef6579a749 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 10e25d8717..ef6579a749 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 83b5f6181c..a4462c23b5 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 efb1bc19cd..5b0fbf2027 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 83b5f6181c..a4462c23b5 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 430815c638..c7a2005ffd 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 cea7f39ce6..5556b3a701 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 64929d7f07..fdd2a28393 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 83b5f6181c..a4462c23b5 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 fe57f118d0..5ce6077444 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 fece3b1d1f..0000000000 --- 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 950198e014..54e7e77e45 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 fece3b1d1f..0000000000 --- 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 950198e014..54e7e77e45 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 0339b6e31e..b43a5238d8 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 e671e5b13e..c1b190d6e8 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 ccd37e81c8..e41b638d28 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 0000000000..6b55ac80f9 --- /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 cc646f13a5..c352c1047a 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 17622c66b9..9f00d6a971 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 4c755476d7..28ad7b64bd 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 fece3b1d1f..0000000000 --- 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 950198e014..54e7e77e45 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 cc646f13a5..c352c1047a 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 2c08590e2e..0a70875178 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 4c755476d7..28ad7b64bd 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 fece3b1d1f..0000000000 --- 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 950198e014..54e7e77e45 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 cc646f13a5..c352c1047a 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 2c08590e2e..0a70875178 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 4c755476d7..28ad7b64bd 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 fece3b1d1f..0000000000 --- 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 0000000000..54e7e77e45 --- /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 cc646f13a5..c352c1047a 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 248978c90d..dba67f37ef 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 4c755476d7..28ad7b64bd 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 fbac79053b..83305b41f7 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 8c006c0d80..cab3c70195 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 fbac79053b..83305b41f7 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 0000000000..6b55ac80f9 --- /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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 fbac79053b..83305b41f7 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 0000000000..6b55ac80f9 --- /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 0339b6e31e..b43a5238d8 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 e671e5b13e..c1b190d6e8 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 fbac79053b..83305b41f7 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 bdea4782ea..cf95338106 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 fbac79053b..83305b41f7 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 0000000000..6b55ac80f9 --- /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 cc646f13a5..c352c1047a 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 17622c66b9..a0bd869cba 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 4c755476d7..28ad7b64bd 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 950198e014..0000000000 --- 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 fbac79053b..83305b41f7 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 0000000000..6b55ac80f9 --- /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 cc646f13a5..c352c1047a 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 17622c66b9..a0bd869cba 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 4c755476d7..28ad7b64bd 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 950198e014..0000000000 --- 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 fbac79053b..83305b41f7 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 0000000000..6b55ac80f9 --- /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 cc646f13a5..c352c1047a 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 17622c66b9..a0bd869cba 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 4c755476d7..28ad7b64bd 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 950198e014..0000000000 --- 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 fbac79053b..83305b41f7 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 0000000000..6b55ac80f9 --- /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 cc646f13a5..c352c1047a 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 d7073900a6..c5aadf7ee1 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 4c755476d7..28ad7b64bd 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 0339b6e31e..b43a5238d8 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 492b157bfa..87f3a1faff 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 0339b6e31e..b43a5238d8 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 1d08e66f14..2a6c260990 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 0339b6e31e..b43a5238d8 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 908d5cbec9..97bd27233b 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 f9331f0a1e..0d9a49b3f4 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 a2e7d5433b..71bb113048 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 0339b6e31e..b43a5238d8 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 3bd1045c3f..517394ec67 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 0339b6e31e..b43a5238d8 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 a3d6081eb6..902f48ad57 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 0339b6e31e..b43a5238d8 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 885b1c7d18..5fc5875d45 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 0339b6e31e..b43a5238d8 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 73005d2172..7637bb05f7 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 0339b6e31e..b43a5238d8 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 727f7529ed..8ec65de2e7 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 0339b6e31e..b43a5238d8 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 db360dbbd2..076177775a 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 0339b6e31e..b43a5238d8 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 643e6fcaef..55c65c88ec 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 0339b6e31e..b43a5238d8 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 0679a5270b..984824e603 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 0339b6e31e..b43a5238d8 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 9163b485e0..11923fa03a 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 0339b6e31e..b43a5238d8 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 5ff3b9a6e2..6095fbb537 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 0339b6e31e..b43a5238d8 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 4dbcdea88b..9e0894fa20 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 0339b6e31e..b43a5238d8 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 cfb7773685..7755c78be0 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 0339b6e31e..b43a5238d8 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 793b1b8472..e678ceafcc 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 0339b6e31e..b43a5238d8 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 15405bb7c2..51ef367b7a 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 0339b6e31e..b43a5238d8 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 6b4b9490b9..331b1d4ec5 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 0339b6e31e..b43a5238d8 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 c8965f2810..17261bdc85 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 0339b6e31e..b43a5238d8 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 c97aa30dc8..4dadefd72e 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 0339b6e31e..b43a5238d8 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 b840a69cd8..73e0c57a97 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 0339b6e31e..b43a5238d8 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 6906786946..18729b813e 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 0339b6e31e..b43a5238d8 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 a81c6479f8..f9011b1e2f 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 0339b6e31e..b43a5238d8 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 a4ea1ca03b..e74fd5c76d 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 0339b6e31e..b43a5238d8 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 28d7af1d60..143540e0b8 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 0339b6e31e..b43a5238d8 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 0f113e6014..49d10ce0fe 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 0339b6e31e..b43a5238d8 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 29f6d3874b..bf1605beb9 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 0339b6e31e..b43a5238d8 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 fb7cc6bd28..888125c022 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 fdd55cedc5..fcfd74a580 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 2df3499e6c..5eee04adf1 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 3e8c2dc317..3fc4764055 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 0959250192..51d54a06a3 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 3b84b928ca..fae694b9b2 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 0339b6e31e..b43a5238d8 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 653bc66d07..ca352b24f6 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 0339b6e31e..b43a5238d8 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 52d79623a0..437eada2ff 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 0339b6e31e..b43a5238d8 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 626485d0cc..a007c1a319 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 0339b6e31e..b43a5238d8 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 626485d0cc..a007c1a319 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 0339b6e31e..b43a5238d8 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 bc6d278d9d..fb2658a1b6 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 0339b6e31e..b43a5238d8 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 c8043dbaaa..4c71cace9b 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 36d23bebdd..e08eb99ccb 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 08f5a80712..755d0d649b 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 71f2c1e40d..d8c37a6ba5 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 c968befbcc..8092866330 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 4639723fb3..62af858b94 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 c968befbcc..8092866330 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 7e5ae03572..d564215cf5 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 0339b6e31e..b43a5238d8 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 c455f81b4b..bea1260fc1 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 0339b6e31e..b43a5238d8 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 a99c8e7490..df7deafb03 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 0000000000..c5e0605a82 --- /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 84312629c4..0000000000 --- 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 bd8a166a25..0000000000 --- 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 0000000000..14fa2efa12 --- /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 e7b3678caf..0000000000 --- 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 a6d4fdd5bf..0000000000 --- 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 2d5985b319..91bd50dc5d 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 133a54ab98..8952a736aa 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 4ff334ff74..58f593d8a6 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 133a54ab98..8952a736aa 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 4cf0ca9c47..2d511cf078 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 4001df3e99..836288372b 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 7190dd07b7..778e50856f 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 cc646f13a5..c352c1047a 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 6d229fd5d5..c192301321 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 4c755476d7..28ad7b64bd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 5c161731c5..1f8bf6602a 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 cc9dcf8412..ea991c983e 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 ba800b837b..87d807f950 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 9067c31ee3..e6ec9cb52e 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 cc9dcf8412..ea991c983e 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 ba800b837b..87d807f950 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 7c3bc951c1..2b25e622ca 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 ee224cabfa..2660fdee60 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 e31c2880d8..a19022118c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 127e25c29b..353fd0b405 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 01f8e2d247..7d91375f4c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 6850887fc8..75d351cb2b 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 fda250e999..bd00301472 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 cc71b7997e..2e9bb8e0bd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 4dfbf97a81..89d6c36e26 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 ade1691a24..015d0c2412 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 c4d0314518..0ecbef3818 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 80cf0ec007..e28573f3a7 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 df3b287f42..36484b5ca0 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 bddcb34e92..0ce0192c4f 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 e150db91be..a2ba96f005 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 392d846215..6bc30992cb 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 c8e3b0f3fc..2e10ae9efb 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 822ebb27de..911c37db39 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 e883dc5376..e468d7e86a 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 98f162bebb..6649417560 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 cbbcb26a7b..8e51a85ecd 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 353557eb6a..95671b708b 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 4001df3e99..836288372b 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 c86860577e..3b0e94261d 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 f46dd8f72f..27214c60f4 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 cc646f13a5..c352c1047a 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 cac41b9477..11a2d3aff0 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 83b5f6181c..a4462c23b5 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 c21b03b976..d9efc68660 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 950198e014..6b55ac80f9 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 cc646f13a5..c352c1047a 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 17622c66b9..1dfac4e45f 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 4c755476d7..28ad7b64bd 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 463216f2d8..bb9cf3b212 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 30f73c51c3..5558f1fec7 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 4001df3e99..836288372b 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 f7b237f6a1..0078ac95d2 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 0339b6e31e..b43a5238d8 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 4c755476d7..28ad7b64bd 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 0339b6e31e..b43a5238d8 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 ec2aea8407..1f09220444 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 0339b6e31e..b43a5238d8 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 a40131f08f..afabab20e2 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 0339b6e31e..b43a5238d8 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 2faa0ef992..ac23756f12 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 0339b6e31e..b43a5238d8 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 2faa0ef992..ac23756f12 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 0339b6e31e..b43a5238d8 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 1db5e50522..aadaa30659 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 2b1dad28ca..5e0213cae0 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 7cd25c229a..41519aa51f 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 5f3be6607c..452f08b23b 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 579f645ec1..f0896eeeaa 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 8e56592817..d5b1bcc1de 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 579f645ec1..f0896eeeaa 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 8e56592817..d5b1bcc1de 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 579f645ec1..f0896eeeaa 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 8e56592817..d5b1bcc1de 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 579f645ec1..f0896eeeaa 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 53f8b21772..fd7b9d4cce 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 0339b6e31e..b43a5238d8 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 02482e56af..d7a0ac4610 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 40a25a497a..b406d8bb9c 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 ea6b3e42ab..d3fe8ca92c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 1f0d8da6ec..213e032f23 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 a360dc82e1..e8552bf4da 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 40a25a497a..b406d8bb9c 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 ea6b3e42ab..d3fe8ca92c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 40a25a497a..b406d8bb9c 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 ea6b3e42ab..d3fe8ca92c 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 ce345c77cc..3bd2706832 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 a360dc82e1..e8552bf4da 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 0339b6e31e..b43a5238d8 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 521723fb3a..21f18eeea6 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 9336baf5a1..36c9e46797 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 e2bd161643..f3fe6fe4c5 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 c3a28994ce..820d528e10 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 ab403042be..354c5b6e2e 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 89be77eab1..fd57de924c 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 fe57f118d0..cab3c70195 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 0339b6e31e..b43a5238d8 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 6f56a64307..5dc1a5f01f 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 0339b6e31e..b43a5238d8 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 b507475fd4..28b3e9b1c3 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 0339b6e31e..b43a5238d8 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 36097cc141..248263eaf3 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 0339b6e31e..b43a5238d8 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 e0db6ccda7..b7bb7bda65 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 2a7a9213e1..57129af5d6 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 39a86f05a7..cebab9b44c 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 ae71709ec1..0fc4ed6062 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 291ad4e825..754fb9f4b1 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 0c5ff38a72..0540b93db9 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 fe57f118d0..cab3c70195 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 cc646f13a5..c352c1047a 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 2b1dad28ca..5e0213cae0 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 7cd25c229a..41519aa51f 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 0339b6e31e..b43a5238d8 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 7ddcc37be9..10f6cc4103 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 950198e014..6b55ac80f9 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 7ddcc37be9..10f6cc4103 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 0339b6e31e..b43a5238d8 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 7ddcc37be9..10f6cc4103 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 0339b6e31e..b43a5238d8 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 7ddcc37be9..10f6cc4103 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 fbac79053b..83305b41f7 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 0000000000..7abbee273e --- /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 dadb04614d..7f48b407e0 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,17 @@ 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]?.toLowerCase(); + // } + // return; + // }, + }, }, pagination: { // keywords: ['aa'], @@ -146,20 +163,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 +200,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 +250,7 @@ export default defineConfig(() => { // mutationOptions: { // name: '{{name}}MO', // }, - // name: '@tanstack/react-query', + name: '@tanstack/react-query', // queryKeys: { // name: '{{name}}QK', // }, @@ -233,7 +265,7 @@ export default defineConfig(() => { if (op.method === 'post' && op.path === '/search') { return ['query']; } - return undefined; + return; }, isMutation() { // noop @@ -248,9 +280,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 +294,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 +324,7 @@ export default defineConfig(() => { }, exportFromIndex: true, metadata: true, - // name: 'zod', + name: 'zod', // requests: { // // case: 'SCREAMING_SNAKE_CASE', // // name: 'z{{name}}TestData', @@ -287,18 +332,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 +368,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 +391,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 0000000000..211b0f00c6 --- /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 0000000000..379f9a0449 --- /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 cc4bc0b808..3b02520b72 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 0000000000..abc26f9e65 --- /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 0000000000..24c4880fad --- /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 e7d8d26463..2241c0dbc2 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 068645092d..33b97c2289 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 5c225d5ee5..582c9ca066 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 6050e6c5e7..528fe0d3d2 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 ffd9033d74..63b277d7af 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 ed27c881f9..d1cbd1460b 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 0000000000..c93fc275c6 --- /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 821e28743f..c862f31bbb 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 0000000000..e73840e1d9 --- /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 0000000000..50b4fafee2 --- /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 dfb05e5113..ed6c1cefc1 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 db575e570d..67cd9d8bf9 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 0b40b33a2d..15bdeb3e2c 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 81f594b60d..7e6cc3c892 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 a08796446b..b74816cd8a 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 ed27c881f9..d1cbd1460b 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/README.md b/packages/openapi-ts/README.md index cbbdfa756d..67ba45e9cf 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 diff --git a/packages/openapi-ts/src/config/output.ts b/packages/openapi-ts/src/config/output.ts index 702c59f741..423a1d3402 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 81acd5b790..d68e87eb2d 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 d5ba1f33b2..8e0332a981 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 4dae89d5bf..ff0c155989 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 44939bc69f..a928ba54c2 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 801c3f38fe..da5b2332ab 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 e822389d95..a0db4be34b 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 55780953f4..af675a5d19 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 ca53a6f964..3e6b44143d 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 212d69ae05..8f685efde2 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 aac442a6fc..def64e47c9 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 face419d9a..8e3a336171 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 c9b1ce7ee9..3fb4d8f90f 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 435e04ba1f..309053d347 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 27fb9fc92d..6307b5e8c2 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 981aa69686..cc1117d460 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 82557cd737..b2357d7cc2 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 b1c4ccf83f..75f1a5fa6d 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 2198ed38fb..2aa311f4dd 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 60af07a369..1cd74e69c3 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 14980bf28b..13748445d2 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 2198ed38fb..2aa311f4dd 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 6ff5e7d2d4..970fbe6225 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 f6e3413ae0..5b5bb9ecd1 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 2ea1bc2989..0000000000 --- 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 c0ef21eb62..4976810132 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 a4695367a3..36b360b8b9 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 78581f485d..3cac308504 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 ca4b4b14dd..70621302dd 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 1712a8fa8a..5d1b7f2358 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 477bb1a302..289723764d 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 47830c53f3..a7d7f73e72 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 163a1bdd99..5af4687d0f 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 71da134b74..9414a28fe2 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 d88c5ce9f3..35c4ee0e9d 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 a567dbad87..3457041ff7 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 3e5ffa3ca4..972f9b6964 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 7b452df79a..aac55bd1be 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 593fdf190c..83c85223d3 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 3b1233a7bc..1a4e9f7420 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 f4de191604..0aa1c5e88d 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 cc0ed614b7..ddb217aa18 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 da6f6864e5..deff71a745 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 ad718d3b44..0deea2b62e 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 d01e5ee1e4..55c9a81368 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 e5d4557749..b0b87b5b60 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 d094bb67fa..fdffdd1acd 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 1804b53962..971228a2e4 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 9ef79067c7..b472c48294 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 9396cb2c0b..967510fa55 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 d4a2eb5a8b..5615310ec4 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 13850e90d6..9493b70198 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 7f1edd5ac2..15ddccb175 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 d83fd1b55c..ffd5d7ad75 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 8cfd735ea4..714207fb98 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 8fbf60bf9c..920c22e804 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 7eeb61cd53..53a7ef0aef 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 b21d59a794..4e1e949713 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 18261c3d58..aa203c16f7 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 c14b4edad0..5ac02deac4 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 547a55dbb7..a01dcea790 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 2513cee151..9ddaef1719 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 5500d8f829..eafcc5e40c 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 b812d78573..ac3575b97b 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 7908f08fbc..13171b12cb 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 75c27d05fa..b2be1fa9a2 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 2569244663..008d945e2b 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 d376378f2e..5722a2fe50 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 fbdf1e24b7..003f6238da 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 c39694fb68..4539a468e1 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 9af1e62aea..8b41d45a35 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 13b181d529..e420831ffb 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 9abd00ca51..9e557afaa5 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 46b7dc1d9f..4de2232854 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 073f2d5ec6..6903791614 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 05e82ebec6..6449279b57 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 cb952f3e62..0000000000 --- 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 26ed75c91b..a69bd0445e 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 82eac2291c..245051b8af 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 357aff01d9..9086df45f5 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 96fe6a7ff4..76d319b8f9 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 985a2f4c41..6b33b233a6 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 02f2ea0e12..f415010a2e 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 8b0ce9a8e8..73baee2760 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 329fd7fd12..08a80d3705 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 c32b7dc768..784d096cc7 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 91fb266400..d765a8545d 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 fb3af4449d..a77b1622c2 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 12bb95829a..41f0b66243 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 deb578eaa8..33357cb955 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 85c5493d47..4a0de32511 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 4a7a1c027e..b21c391db4 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 9ac1e9467c..2758857b12 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 7cd44eb331..db6b292e6f 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 9a343483cd..2ff589aec8 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 ea1bf20809..72a6c77b09 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 accee34a22..99562511ed 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 8ec88344e0..b8b2cd8f7c 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 31a440609f..6db1882948 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 efa0ccaad6..7c79bcbdca 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 ec050bcdad..541c5c848a 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 d4981a17b5..332d7ea4c1 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 b64aec43a7..fc0c76cb7e 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 78b24d3904..be4b955e83 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 6b45870d1c..a6f4d85f64 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 033ec060ea..02770a559c 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 f45ac44963..dac9266d53 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 77aa179e6e..2d560d4eaf 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 0aae05ee44..9d64064fa0 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 2e938cfafd..0c78dc943e 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 585fb1f5a8..a025ed339b 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 676229b4f1..21c836849b 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 1a1f6bfd3b..1fdb02e02d 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 89215872de..b4b4f7dd14 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 5e8374943e..fc753cffb8 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 df4eb05e0c..e5bc03a25c 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 a54a7e9032..1562be1db2 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 e4f28b3e31..e6c89a4179 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 a71d81a6ee..0312b21242 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 a762bc8c37..ad1b4e2b4f 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 6b85941aff..94b483bb00 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 6150639e40..2c683ed439 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 45bea2a946..e0cec7036b 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: {},