From 5e098fd598a586d57e621a2905da670851ec8fa8 Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 30 Oct 2025 07:33:57 +0800 Subject: [PATCH] feat: remove symbol selectors --- dev/openapi-ts.config.ts | 6 +- .../src/__tests__/exports.test.ts | 3 +- .../src/__tests__/project.test.ts | 4 +- .../src/__tests__/symbols.test.ts | 75 ++++------- packages/codegen-core/src/files/registry.ts | 38 +++--- packages/codegen-core/src/files/types.d.ts | 33 +++-- packages/codegen-core/src/index.ts | 7 +- packages/codegen-core/src/project/project.ts | 5 +- .../codegen-core/src/selectors/types.d.ts | 8 -- packages/codegen-core/src/symbols/registry.ts | 122 ++---------------- packages/codegen-core/src/symbols/types.d.ts | 19 +-- .../sdk-nested-classes-instance/sdk.gen.ts | 2 + .../sdk-nested-classes/sdk.gen.ts | 2 + .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 2 + .../plugins/@pinia/colada/asClass/sdk.gen.ts | 3 + .../asClass/sdk.gen.ts | 3 + .../@tanstack/react-query/asClass/sdk.gen.ts | 3 + .../@tanstack/solid-query/asClass/sdk.gen.ts | 3 + .../@tanstack/svelte-query/asClass/sdk.gen.ts | 3 + .../@tanstack/vue-query/asClass/sdk.gen.ts | 3 + .../sdk-nested-classes-instance/sdk.gen.ts | 2 + .../sdk-nested-classes/sdk.gen.ts | 2 + .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 2 + .../plugins/@pinia/colada/asClass/sdk.gen.ts | 3 + .../asClass/sdk.gen.ts | 3 + .../@tanstack/react-query/asClass/sdk.gen.ts | 3 + .../@tanstack/solid-query/asClass/sdk.gen.ts | 3 + .../@tanstack/svelte-query/asClass/sdk.gen.ts | 3 + .../@tanstack/vue-query/asClass/sdk.gen.ts | 3 + .../sdk-nested-classes-instance/sdk.gen.ts | 2 + .../sdk-nested-classes/sdk.gen.ts | 2 + .../plugins/@hey-api/sdk/instance/sdk.gen.ts | 2 + .../plugins/@pinia/colada/asClass/sdk.gen.ts | 3 + .../asClass/sdk.gen.ts | 3 + .../@tanstack/react-query/asClass/sdk.gen.ts | 3 + .../@tanstack/solid-query/asClass/sdk.gen.ts | 3 + .../@tanstack/svelte-query/asClass/sdk.gen.ts | 3 + .../@tanstack/vue-query/asClass/sdk.gen.ts | 3 + .../src/generate/__tests__/class.test.ts | 8 +- .../src/generate/__tests__/core.test.ts | 24 +--- .../generate/legacy/__tests__/index.test.ts | 8 +- .../generate/legacy/__tests__/output.test.ts | 8 +- .../schemas/__tests__/schemas.test.ts | 16 +-- .../@hey-api/sdk/__tests__/plugin.test.ts | 32 ++--- .../src/plugins/@hey-api/sdk/shared/class.ts | 87 ++++++++----- .../typescript/__tests__/plugin.test.ts | 8 +- .../src/plugins/shared/utils/instance.ts | 4 +- .../src/utils/__tests__/handlebars.test.ts | 16 +-- .../src/utils/__tests__/parse.test.ts | 28 +--- 49 files changed, 263 insertions(+), 368 deletions(-) delete mode 100644 packages/codegen-core/src/selectors/types.d.ts diff --git a/dev/openapi-ts.config.ts b/dev/openapi-ts.config.ts index 49cf75c92..818d7a905 100644 --- a/dev/openapi-ts.config.ts +++ b/dev/openapi-ts.config.ts @@ -248,10 +248,10 @@ export default defineConfig(() => { // }, }, { - // asClass: true, + asClass: true, // auth: false, // classNameBuilder: '{{name}}', - // classNameBuilder: '{{name}}Service', + classNameBuilder: '{{name}}Service', // classStructure: 'off', // client: false, // getSignature: ({ fields, signature, operation }) => { @@ -259,7 +259,7 @@ export default defineConfig(() => { // fields.unwrap('path') // }, // include... - instance: true, + // instance: true, name: '@hey-api/sdk', // operationId: false, // params_EXPERIMENTAL: 'experiment', diff --git a/packages/codegen-core/src/__tests__/exports.test.ts b/packages/codegen-core/src/__tests__/exports.test.ts index 36a664ada..6d97ef1fa 100644 --- a/packages/codegen-core/src/__tests__/exports.test.ts +++ b/packages/codegen-core/src/__tests__/exports.test.ts @@ -11,12 +11,13 @@ export type _TypeExports = [ index.ProjectRenderMeta, index.SymbolMeta, index.File, + index.FileIdentifier, index.FileIn, index.Output, index.IProject, index.Renderer, - index.Selector, index.Symbol, + index.SymbolIdentifier, index.SymbolIn, ]; diff --git a/packages/codegen-core/src/__tests__/project.test.ts b/packages/codegen-core/src/__tests__/project.test.ts index d7f2a70a6..53e95e82c 100644 --- a/packages/codegen-core/src/__tests__/project.test.ts +++ b/packages/codegen-core/src/__tests__/project.test.ts @@ -23,8 +23,8 @@ describe('Project', () => { // Add a symbol and render output const symbol = project.symbols.register({ getFilePath: () => 'foo', + meta: { foo: 'bar' }, placeholder: 'Foo', - selector: ['foo'], }); // Add a renderer for .ts files // Simulate a file with .ts extension @@ -80,8 +80,8 @@ describe('Project', () => { // Register a symbol with selector project.symbols.register({ getFilePath: () => 'bar', + meta: { bar: 'baz' }, placeholder: 'Bar', - selector: ['bar'], }); // Render output (should use fileName override) const outputs = project.render(); diff --git a/packages/codegen-core/src/__tests__/symbols.test.ts b/packages/codegen-core/src/__tests__/symbols.test.ts index f8018bdd7..c989bc7d7 100644 --- a/packages/codegen-core/src/__tests__/symbols.test.ts +++ b/packages/codegen-core/src/__tests__/symbols.test.ts @@ -11,67 +11,62 @@ describe('SymbolRegistry', () => { expect(typeof id1).toBe('number'); expect(id2).toBe(id1 + 1); - // Register a symbol with selector + // Register a symbol with meta const symbol1 = registry.register({ + meta: { + foo: 'bar', + }, placeholder: 'Foo', - selector: ['foo'], }); expect(symbol1).toEqual({ exportFrom: [], id: expect.any(Number), + meta: { + foo: 'bar', + }, placeholder: 'Foo', - selector: ['foo'], }); - // get by id and selector + // get by id and meta expect(registry.get(symbol1.id)).toEqual(symbol1); - expect(registry.get(['foo'])).toEqual(symbol1); + expect(registry.get({ foo: 'bar' })).toEqual(symbol1); // isRegistered should be true for explicitly registered symbols expect(registry.isRegistered(symbol1.id)).toBe(true); - expect(registry.isRegistered(['foo'])).toBe(true); + expect(registry.isRegistered({ foo: 'bar' })).toBe(true); - // Registering again with same selector returns same symbol - const symbol1b = registry.register({ selector: ['foo'] }); - expect(symbol1b).toEqual(symbol1); + // Registering again with same meta creates a new symbol + const symbol1b = registry.register({ meta: { foo: 'bar' } }); + expect(symbol1b).not.toEqual(symbol1); - // Registering with id returns same symbol + // Registering with id overrides the symbol const symbol1c = registry.register({ id: symbol1.id }); - expect(symbol1c).toEqual(symbol1); + expect(symbol1c).not.toEqual(symbol1); + expect(symbol1c.id).toBe(symbol1.id); - // Reference by id returns same symbol - const ref1 = registry.reference(symbol1.id); - expect(ref1).toEqual(symbol1); + // Reference returns same symbol + const ref1 = registry.reference({ foo: 'bar' }); + expect(ref1).toEqual(symbol1c); - // Reference by selector returns same symbol - const ref1b = registry.reference(['foo']); - expect(ref1b).toEqual(symbol1); - - // Register a new symbol with a different selector + // Register a new symbol with different meta const symbol2 = registry.register({ exportFrom: ['x'], + meta: { bar: 'baz' }, placeholder: 'Bar', - selector: ['bar'], }); expect(symbol2).toEqual({ exportFrom: ['x'], id: expect.any(Number), + meta: { bar: 'baz' }, 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'] }), + expect.objectContaining({ id: 2 }), + expect.objectContaining({ meta: { foo: 'bar' } }), + expect.objectContaining({ meta: { bar: 'baz' } }), ]); // setValue, getValue, hasValue @@ -80,12 +75,12 @@ describe('SymbolRegistry', () => { expect(registry.hasValue(symbol1.id)).toBe(true); expect(registry.getValue(symbol1.id)).toBe(42); - // referenced-only symbol should not be registered until register() with data - const symRef = registry.reference(['qux']); + // referenced-only symbol should not be registered until register() + const symRef = registry.reference({ qux: true }); expect(registry.isRegistered(symRef.id)).toBe(false); const symRegistered = registry.register({ + meta: { qux: true }, placeholder: 'Qux', - selector: ['qux'], }); expect(registry.isRegistered(symRegistered.id)).toBe(true); }); @@ -136,20 +131,6 @@ describe('SymbolRegistry', () => { expect(symC.meta).toEqual({ a: 0, b: 0, c: 0 }); }); - 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.', - ); - }); - it('caches query results and invalidates on relevant updates', () => { const registry = new SymbolRegistry(); const symA = registry.register({ meta: { foo: 'bar' }, name: 'A' }); diff --git a/packages/codegen-core/src/files/registry.ts b/packages/codegen-core/src/files/registry.ts index e5c9f47d5..cd89e62dd 100644 --- a/packages/codegen-core/src/files/registry.ts +++ b/packages/codegen-core/src/files/registry.ts @@ -1,6 +1,10 @@ import { BiMap } from '../bimap/bimap'; -import type { ISelector } from '../selectors/types'; -import type { IFileIn, IFileOut, IFileRegistry } from './types'; +import type { + IFileIdentifier, + IFileIn, + IFileOut, + IFileRegistry, +} from './types'; export class FileRegistry implements IFileRegistry { private _id: number = 0; @@ -9,17 +13,15 @@ export class FileRegistry implements IFileRegistry { private selectorToId: Map = new Map(); private values: Map = new Map(); - get(fileIdOrSelector: number | ISelector): IFileOut | undefined { - const symbol = this.idOrSelector(fileIdOrSelector); + get(identifier: IFileIdentifier): IFileOut | undefined { + const file = this.identifierToFile(identifier); - if (symbol.id !== undefined) { - return this.values.get(symbol.id); + if (file.id !== undefined) { + return this.values.get(file.id); } const selector = - symbol.selector !== undefined - ? JSON.stringify(symbol.selector) - : undefined; + file.selector !== undefined ? JSON.stringify(file.selector) : undefined; if (selector) { const id = this.selectorToId.get(selector); @@ -35,21 +37,21 @@ export class FileRegistry implements IFileRegistry { return this._id++; } - private idOrSelector( - symbolIdOrSelector: number | ISelector, + private identifierToFile( + identifier: IFileIdentifier, ): Pick { - return typeof symbolIdOrSelector === 'number' - ? { id: symbolIdOrSelector } - : { selector: symbolIdOrSelector }; + return typeof identifier === 'number' + ? { id: identifier } + : { selector: identifier }; } - isRegistered(fileIdOrSelector: number | ISelector): boolean { - const file = this.get(fileIdOrSelector); + isRegistered(identifier: IFileIdentifier): boolean { + const file = this.get(identifier); return file ? this.registerOrder.has(file.id) : false; } - reference(fileIdOrSelector: number | ISelector): IFileOut { - const file = this.idOrSelector(fileIdOrSelector); + reference(identifier: IFileIdentifier): IFileOut { + const file = this.identifierToFile(identifier); return this.register(file); } diff --git a/packages/codegen-core/src/files/types.d.ts b/packages/codegen-core/src/files/types.d.ts index 2c9f37ae2..78dfcefaf 100644 --- a/packages/codegen-core/src/files/types.d.ts +++ b/packages/codegen-core/src/files/types.d.ts @@ -1,5 +1,13 @@ import type { IBiMap } from '../bimap/types'; -import type { ISelector } from '../selectors/types'; + +/** + * Selector array used to reference files. + * + * @example ["foo", "bar"] + */ +export type IFileSelector = ReadonlyArray; + +export type IFileIdentifier = number | IFileSelector; export interface IFileIn { /** @@ -32,12 +40,11 @@ export interface IFileIn { */ readonly path?: string; /** - * Selector array used to select this file. It doesn't have to be - * unique, but in practice it might be desirable. + * Selector array used to select this file. * - * @example ["zod", "#/components/schemas/Foo"] + * @example ["foo", "bar"] */ - readonly selector?: ISelector; + readonly selector?: IFileSelector; } export interface IFileOut extends IFileIn { @@ -70,12 +77,12 @@ export interface IFileOut extends IFileIn { export interface IFileRegistry { /** - * Get a file by its ID. + * Get a file. * - * @param fileIdOrSelector File ID or selector to reference. + * @param identifier File identifier to reference. * @returns The file, or undefined if not found. */ - get(fileIdOrSelector: number | ISelector): IFileOut | undefined; + get(identifier: IFileIdentifier): IFileOut | undefined; /** * Returns the current file ID and increments it. * @@ -85,17 +92,17 @@ export interface IFileRegistry { /** * Returns whether a file is registered in the registry. * - * @param fileIdOrSelector File ID or selector to check. + * @param identifier File identifier to check. * @returns True if the file is registered, false otherwise. */ - isRegistered(fileIdOrSelector: number | ISelector): boolean; + isRegistered(identifier: IFileIdentifier): boolean; /** - * Returns a file by ID or selector, registering it if it doesn't exist. + * Returns a file by identifier, registering it if it doesn't exist. * - * @param fileIdOrSelector File ID or selector to reference. + * @param identifier File identifier to reference. * @returns The referenced or newly registered file. */ - reference(fileIdOrSelector: number | ISelector): IFileOut; + reference(identifier: IFileIdentifier): IFileOut; /** * Get all unregistered files in the order they were referenced. * diff --git a/packages/codegen-core/src/index.ts b/packages/codegen-core/src/index.ts index cd27c3bfe..22d8c0fd8 100644 --- a/packages/codegen-core/src/index.ts +++ b/packages/codegen-core/src/index.ts @@ -5,13 +5,16 @@ export type { IProjectRenderMeta as ProjectRenderMeta, ISymbolMeta as SymbolMeta, } from './extensions/types'; -export type { IFileOut as File, IFileIn as FileIn } from './files/types'; +export type { + IFileOut as File, + IFileIdentifier as FileIdentifier, + 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, ISymbolIdentifier as SymbolIdentifier, diff --git a/packages/codegen-core/src/project/project.ts b/packages/codegen-core/src/project/project.ts index cbdc58421..ee6d3a395 100644 --- a/packages/codegen-core/src/project/project.ts +++ b/packages/codegen-core/src/project/project.ts @@ -2,10 +2,9 @@ import path from 'node:path'; import type { IProjectRenderMeta } from '../extensions/types'; import { FileRegistry } from '../files/registry'; -import type { IFileOut } from '../files/types'; +import type { IFileOut, IFileSelector } 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'; @@ -132,7 +131,7 @@ export class Project implements IProject { return Array.from(fileIds ?? []).map((fileId) => this.files.get(fileId)!); } - private symbolToFileSelector(symbol: ISymbolOut): ISelector { + private symbolToFileSelector(symbol: ISymbolOut): IFileSelector { if (symbol.external) { return [externalSourceSymbol, symbol.external]; } diff --git a/packages/codegen-core/src/selectors/types.d.ts b/packages/codegen-core/src/selectors/types.d.ts deleted file mode 100644 index de02b27a5..000000000 --- a/packages/codegen-core/src/selectors/types.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Selector array used to reference resources. We don't enforce - * uniqueness, but in practice it's desirable. - * - * @deprecated - * @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 index ad0626839..5cb58128c 100644 --- a/packages/codegen-core/src/symbols/registry.ts +++ b/packages/codegen-core/src/symbols/registry.ts @@ -21,38 +21,14 @@ export class SymbolRegistry implements ISymbolRegistry { private queryCacheDependencies: Map> = new Map(); private registerOrder: Set = new Set(); - // TODO: remove after removing selectors - private selectorToId: Map = new Map(); private stubCache: Map = new Map(); private stubs: Set = new Set(); private values: Map = new Map(); get(identifier: ISymbolIdentifier): ISymbolOut | undefined { - const symbol = this.identifierToSymbol(identifier); - - if (symbol.id !== undefined) { - return this.values.get(symbol.id); - } - - // TODO: remove after removing selectors - const selector = - symbol.selector !== undefined - ? JSON.stringify(symbol.selector) - : undefined; - - // TODO: remove after removing selectors - if (selector) { - const id = this.selectorToId.get(selector); - if (id !== undefined) { - return this.values.get(id); - } - } - - if (symbol.meta) { - return this.query(symbol.meta)[0]; - } - - return; + return typeof identifier === 'number' + ? this.values.get(identifier) + : this.query(identifier)[0]; } getValue(symbolId: SymbolId): unknown { @@ -111,22 +87,17 @@ export class SymbolRegistry implements ISymbolRegistry { return resultIds.map((symbolId) => this.values.get(symbolId)!); } - reference(identifier: ISymbolIdentifier): ISymbolOut { - const symbol = this.identifierToSymbol(identifier); - if (!symbol.meta) { - // TODO: remove/refactor after removing selectors - return this.register(symbol); - } - const [registered] = this.query(symbol.meta); + reference(meta: ISymbolMeta): ISymbolOut { + const [registered] = this.query(meta); if (registered) return registered; - const cacheKey = this.buildCacheKey(symbol.meta); + const cacheKey = this.buildCacheKey(meta); const cachedId = this.stubCache.get(cacheKey); if (cachedId !== undefined) return this.values.get(cachedId)!; const id = this.id; const stub: ISymbolOut = { exportFrom: [], id, - meta: symbol.meta, + meta, placeholder: wrapId(String(id)), }; this.values.set(stub.id, stub); @@ -136,77 +107,21 @@ export class SymbolRegistry implements ISymbolRegistry { } register(symbol: ISymbolIn): ISymbolOut { - // TODO: refactor after removing selectors - 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; - } - - // TODO: refactor after removing selectors - const hasOtherKeys = Object.keys(symbol).some( - (key) => !['id', 'meta', 'selector'].includes(key), - ); - - let result: ISymbolOut | undefined; - - // TODO: remove after removing selectors - 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, + const id = symbol.id !== undefined ? symbol.id : this.id; + const result: ISymbolOut = { ...symbol, // clone to avoid mutation - exportFrom, + exportFrom: symbol.exportFrom ?? [], id, - placeholder: - result?.placeholder ?? symbol.placeholder ?? wrapId(String(id)), + placeholder: symbol.placeholder ?? wrapId(String(id)), }; this.values.set(result.id, result); - - if (hasOtherKeys) { - this.registerOrder.add(result.id); - } - - if (selector) { - // TODO: remove after removing selectors - this.selectorToId.set(selector, result.id); - } - + this.registerOrder.add(result.id); if (result.meta) { const indexKeySpace = this.buildIndexKeySpace(result.meta); this.indexSymbol(result.id, indexKeySpace); this.invalidateCache(indexKeySpace); this.replaceStubs(result, indexKeySpace); } - return result; } @@ -241,19 +156,6 @@ export class SymbolRegistry implements ISymbolRegistry { return entries; } - private identifierToSymbol( - identifier: ISymbolIdentifier, - ): Pick { - if (typeof identifier === 'number') { - return { id: identifier }; - } - if (identifier instanceof Array) { - // TODO: remove after removing selectors - return { selector: identifier }; - } - return { meta: identifier }; - } - private indexSymbol(symbolId: SymbolId, indexKeySpace: IndexKeySpace): void { for (const [key, value] of indexKeySpace) { if (!this.indices.has(key)) this.indices.set(key, new Map()); diff --git a/packages/codegen-core/src/symbols/types.d.ts b/packages/codegen-core/src/symbols/types.d.ts index b632bddf3..cb87ed675 100644 --- a/packages/codegen-core/src/symbols/types.d.ts +++ b/packages/codegen-core/src/symbols/types.d.ts @@ -1,7 +1,6 @@ import type { ISymbolMeta } from '../extensions/types'; -import type { ISelector } from '../selectors/types'; -export type ISymbolIdentifier = number | ISymbolMeta | ISelector; +export type ISymbolIdentifier = number | ISymbolMeta; export interface ISymbolIn { /** @@ -60,14 +59,6 @@ export interface ISymbolIn { * @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. - * - * @deprecated - * @example ["zod", "#/components/schemas/Foo"] - */ - readonly selector?: ISelector; } export interface ISymbolOut extends ISymbolIn { @@ -130,12 +121,12 @@ export interface ISymbolRegistry { */ query(filter: ISymbolMeta): ReadonlyArray; /** - * Returns a symbol, registers it if it doesn't exist. + * References a symbol. * - * @param identifier Symbol identifier to reference. - * @returns The referenced or newly registered symbol. + * @param meta Metadata filter to reference symbol by. + * @returns The referenced symbol. */ - reference(identifier: ISymbolIdentifier): ISymbolOut; + reference(meta: ISymbolMeta): ISymbolOut; /** * Register a symbol globally. * 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 d4599e2ea..37c921424 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 @@ -57,6 +57,7 @@ export class Business extends _HeyApiClient { ...options }); } + providers = new Providers({ client: this._client }); } @@ -74,5 +75,6 @@ export class NestedSdkWithInstance extends _HeyApiClient { ...options }); } + business = new Business({ client: this._client }); } 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 b6d733c5f..a0f9707ef 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 @@ -52,6 +52,7 @@ export class Business { ...options }); } + static providers = Providers; } @@ -62,5 +63,6 @@ export class Locations { ...options }); } + static business = Business; } 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 c2d474c60..5c3fa0664 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 @@ -60,6 +60,7 @@ export class Foo extends _HeyApiClient { ...options }); } + bar = new Bar({ client: this._client }); } @@ -77,5 +78,6 @@ export class Sdk extends _HeyApiClient { ...options }); } + foo = new Foo({ client: this._client }); } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 d4599e2ea..37c921424 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 @@ -57,6 +57,7 @@ export class Business extends _HeyApiClient { ...options }); } + providers = new Providers({ client: this._client }); } @@ -74,5 +75,6 @@ export class NestedSdkWithInstance extends _HeyApiClient { ...options }); } + business = new Business({ client: this._client }); } 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 b6d733c5f..a0f9707ef 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 @@ -52,6 +52,7 @@ export class Business { ...options }); } + static providers = Providers; } @@ -62,5 +63,6 @@ export class Locations { ...options }); } + static business = Business; } 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 c2d474c60..5c3fa0664 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 @@ -60,6 +60,7 @@ export class Foo extends _HeyApiClient { ...options }); } + bar = new Bar({ client: this._client }); } @@ -77,5 +78,6 @@ export class Sdk extends _HeyApiClient { ...options }); } + foo = new Foo({ client: this._client }); } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 d4599e2ea..37c921424 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 @@ -57,6 +57,7 @@ export class Business extends _HeyApiClient { ...options }); } + providers = new Providers({ client: this._client }); } @@ -74,5 +75,6 @@ export class NestedSdkWithInstance extends _HeyApiClient { ...options }); } + business = new Business({ client: this._client }); } 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 b6d733c5f..a0f9707ef 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 @@ -52,6 +52,7 @@ export class Business { ...options }); } + static providers = Providers; } @@ -62,5 +63,6 @@ export class Locations { ...options }); } + static business = Business; } 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 c2d474c60..5c3fa0664 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 @@ -60,6 +60,7 @@ export class Foo extends _HeyApiClient { ...options }); } + bar = new Bar({ client: this._client }); } @@ -77,5 +78,6 @@ export class Sdk extends _HeyApiClient { ...options }); } + foo = new Foo({ client: this._client }); } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } 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 e7afaa9a7..fdfe39f10 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 @@ -48,6 +48,7 @@ export class FooService { ...options }); } + static barService = BarService; } @@ -58,6 +59,7 @@ export class FooBazService { ...options }); } + static fooService = FooService; } @@ -68,5 +70,6 @@ export class BarBazService { ...options }); } + static fooService = FooService; } diff --git a/packages/openapi-ts/src/generate/__tests__/class.test.ts b/packages/openapi-ts/src/generate/__tests__/class.test.ts index e176c3f47..a4ef247c1 100644 --- a/packages/openapi-ts/src/generate/__tests__/class.test.ts +++ b/packages/openapi-ts/src/generate/__tests__/class.test.ts @@ -85,9 +85,7 @@ describe('generateLegacyClientClass', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -96,9 +94,7 @@ describe('generateLegacyClientClass', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, diff --git a/packages/openapi-ts/src/generate/__tests__/core.test.ts b/packages/openapi-ts/src/generate/__tests__/core.test.ts index 21e18ee16..4422ebdb0 100644 --- a/packages/openapi-ts/src/generate/__tests__/core.test.ts +++ b/packages/openapi-ts/src/generate/__tests__/core.test.ts @@ -100,9 +100,7 @@ describe('generateLegacyCore', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -111,9 +109,7 @@ describe('generateLegacyCore', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, @@ -256,9 +252,7 @@ describe('generateLegacyCore', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -267,9 +261,7 @@ describe('generateLegacyCore', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, @@ -395,9 +387,7 @@ describe('generateLegacyCore', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -406,9 +396,7 @@ describe('generateLegacyCore', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, 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 a77a6382d..63da2a694 100644 --- a/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts +++ b/packages/openapi-ts/src/generate/legacy/__tests__/index.test.ts @@ -84,9 +84,7 @@ describe('generateIndexFile', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -95,9 +93,7 @@ describe('generateIndexFile', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, 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 c7d1790d2..3fc012aa1 100644 --- a/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts +++ b/packages/openapi-ts/src/generate/legacy/__tests__/output.test.ts @@ -97,9 +97,7 @@ describe('generateLegacyOutput', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -108,9 +106,7 @@ describe('generateLegacyOutput', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, 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 333355eaa..589c8ae06 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 @@ -88,9 +88,7 @@ describe('generateLegacySchemas', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -99,9 +97,7 @@ describe('generateLegacySchemas', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, @@ -256,9 +252,7 @@ describe('generateLegacySchemas', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', nameBuilder: nameFn, @@ -268,9 +262,7 @@ describe('generateLegacySchemas', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, 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 cfc4925b4..e03e4d0a3 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 @@ -90,9 +90,7 @@ describe('handlerLegacy', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -101,9 +99,7 @@ describe('handlerLegacy', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { asClass: true, name: '@hey-api/sdk', @@ -331,9 +327,7 @@ describe('methodNameBuilder', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -342,9 +336,7 @@ describe('methodNameBuilder', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { asClass: true, name: '@hey-api/sdk', @@ -494,9 +486,7 @@ describe('methodNameBuilder', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -505,9 +495,7 @@ describe('methodNameBuilder', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { asClass: true, methodNameBuilder, @@ -660,9 +648,7 @@ describe('methodNameBuilder', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -671,9 +657,7 @@ describe('methodNameBuilder', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { asClass: false, methodNameBuilder, diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts index f93341a3d..d5359be80 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts @@ -167,7 +167,7 @@ export const generateClassSdk = ({ }); if (!sdkClasses.has(symbolCurrentClass.meta!.resourceId!)) { sdkClasses.set(symbolCurrentClass.meta!.resourceId!, { - className: currentClassName, + className: symbolCurrentClass.meta!.resourceId!, classes: new Set(), id: symbolCurrentClass.id, methods: new Set(), @@ -185,7 +185,8 @@ export const generateClassSdk = ({ tool: 'sdk', }); if ( - symbolParentClass.placeholder !== symbolCurrentClass.placeholder + symbolParentClass.meta?.resourceId !== + symbolCurrentClass.meta?.resourceId ) { const parentClass = sdkClasses.get( symbolParentClass.meta!.resourceId!, @@ -303,40 +304,58 @@ export const generateClassSdk = ({ const childClass = sdkClasses.get(childClassName)!; generateClass(childClass); - currentClass.nodes.push( - tsc.propertyDeclaration({ - initializer: plugin.config.instance - ? tsc.newExpression({ - argumentsArray: plugin.config.instance - ? [ - tsc.objectExpression({ - multiLine: false, - obj: [ - { - key: 'client', - value: tsc.propertyAccessExpression({ - expression: tsc.this(), - name: '_client', - }), - }, - ], - }), - ] - : [], - expression: tsc.identifier({ - text: plugin.referenceSymbol(childClass.id).placeholder, - }), - }) - : tsc.identifier({ - text: plugin.referenceSymbol(childClass.id).placeholder, + const subClassReferenceNode = tsc.propertyDeclaration({ + initializer: plugin.config.instance + ? tsc.newExpression({ + argumentsArray: plugin.config.instance + ? [ + tsc.objectExpression({ + multiLine: false, + obj: [ + { + key: 'client', + value: tsc.propertyAccessExpression({ + expression: tsc.this(), + name: '_client', + }), + }, + ], + }), + ] + : [], + expression: tsc.identifier({ + text: plugin.referenceSymbol({ + category: 'utility', + resource: 'class', + resourceId: childClass.className, + tool: 'sdk', + }).placeholder, }), - modifier: plugin.config.instance ? undefined : 'static', - name: stringCase({ - case: 'camelCase', - value: childClass.className, - }), + }) + : tsc.identifier({ + text: plugin.referenceSymbol({ + category: 'utility', + resource: 'class', + resourceId: childClass.className, + tool: 'sdk', + }).placeholder, + }), + modifier: plugin.config.instance ? undefined : 'static', + name: stringCase({ + case: 'camelCase', + value: childClass.className, }), - ); + }); + + if (!currentClass.nodes.length) { + currentClass.nodes.push(subClassReferenceNode); + } else { + currentClass.nodes.push( + // @ts-expect-error + tsc.identifier({ text: '\n' }), + subClassReferenceNode, + ); + } } } 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 e0a3529ae..0a04dd96e 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 @@ -88,9 +88,7 @@ describe('generateLegacyTypes', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -99,9 +97,7 @@ describe('generateLegacyTypes', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, diff --git a/packages/openapi-ts/src/plugins/shared/utils/instance.ts b/packages/openapi-ts/src/plugins/shared/utils/instance.ts index 5380c8b2b..453316440 100644 --- a/packages/openapi-ts/src/plugins/shared/utils/instance.ts +++ b/packages/openapi-ts/src/plugins/shared/utils/instance.ts @@ -302,8 +302,8 @@ export class PluginInstance { return this.gen.symbols.query(filter)[0]; } - referenceSymbol(identifier: SymbolIdentifier): Symbol { - return this.gen.symbols.reference(identifier); + referenceSymbol(meta: SymbolMeta): Symbol { + return this.gen.symbols.reference(meta); } registerSymbol(symbol: SymbolIn): Symbol { diff --git a/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts b/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts index 9dee10e99..549bc30c7 100644 --- a/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts +++ b/packages/openapi-ts/src/utils/__tests__/handlebars.test.ts @@ -81,9 +81,7 @@ describe('registerHandlebarHelpers', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -92,9 +90,7 @@ describe('registerHandlebarHelpers', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, @@ -210,9 +206,7 @@ describe('registerHandlebarTemplates', () => { ], plugins: { '@hey-api/schemas': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/schemas', }, @@ -221,9 +215,7 @@ describe('registerHandlebarTemplates', () => { output: '', }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', }, diff --git a/packages/openapi-ts/src/utils/__tests__/parse.test.ts b/packages/openapi-ts/src/utils/__tests__/parse.test.ts index 304276052..7ddd70b9c 100644 --- a/packages/openapi-ts/src/utils/__tests__/parse.test.ts +++ b/packages/openapi-ts/src/utils/__tests__/parse.test.ts @@ -71,9 +71,7 @@ describe('operationNameFn', () => { pluginOrder: ['legacy/fetch', '@hey-api/sdk'], plugins: { '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', operationId: true, @@ -101,9 +99,7 @@ describe('operationNameFn', () => { plugins: { ...optionsCommon.plugins, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', operationId: true, @@ -121,9 +117,7 @@ describe('operationNameFn', () => { plugins: { ...optionsCommon.plugins, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', operationId: false, @@ -141,9 +135,7 @@ describe('operationNameFn', () => { pluginOrder: ['@hey-api/client-fetch', '@hey-api/sdk'], plugins: { '@hey-api/client-fetch': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/client-fetch', }, @@ -153,9 +145,7 @@ describe('operationNameFn', () => { tags: ['client'], }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', operationId: true, @@ -173,9 +163,7 @@ describe('operationNameFn', () => { pluginOrder: ['@hey-api/client-fetch', '@hey-api/sdk'], plugins: { '@hey-api/client-fetch': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/client-fetch', }, @@ -185,9 +173,7 @@ describe('operationNameFn', () => { tags: ['client'], }, '@hey-api/sdk': { - api: { - selector: () => [], - }, + api: {}, config: { name: '@hey-api/sdk', operationId: false, -- 2.51.2