fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #3604 from hey-api/refactor/py-dsl-returns-mixin

refactor: clean up returns mixin

authored by

Lubos and committed by
GitHub
593fafe6 7a9f6f1d

+3 -15
+3 -15
packages/openapi-python/src/py-dsl/mixins/returns.ts
··· 1 1 import type { AnalysisContext, Node, NodeName } from '@hey-api/codegen-core'; 2 - import { isSymbol } from '@hey-api/codegen-core'; 3 2 4 3 import type { py } from '../../ts-python'; 5 - import { IdPyDsl } from '../expr/identifier'; 6 4 import type { BaseCtor, MixinCtor } from './types'; 7 5 8 6 export interface ReturnsMethods extends Node { ··· 12 10 13 11 export function ReturnsMixin<T extends py.Node, TBase extends BaseCtor<T>>(Base: TBase) { 14 12 abstract class Returns extends Base { 15 - protected _returns?: IdPyDsl | py.Expression; 13 + protected _returns?: NodeName | py.Expression; 16 14 17 15 override analyze(ctx: AnalysisContext): void { 18 16 super.analyze(ctx); ··· 20 18 } 21 19 22 20 returns(type: NodeName | py.Expression): this { 23 - if (typeof type === 'string' || isSymbol(type)) { 24 - this._returns = new IdPyDsl(type); 25 - } else { 26 - this._returns = type as py.Expression; 27 - } 21 + this._returns = type; 28 22 return this; 29 23 } 30 24 31 25 protected $returns(): py.Expression | undefined { 32 - if (!this._returns) { 33 - return; 34 - } 35 - if (this._returns instanceof IdPyDsl) { 36 - return this._returns.toAst(); 37 - } 38 - return this._returns as py.Expression; 26 + return this.$node(this._returns); 39 27 } 40 28 } 41 29