fork of hey-api/openapi-ts because I need some additional things
at feat/skip-token 27 lines 591 B view raw
1import type { AnalysisContext } from '@hey-api/codegen-core'; 2 3import { py } from '../../ts-python'; 4import { PyDsl } from '../base'; 5 6export type LiteralValue = string | number | boolean | null; 7 8const Mixed = PyDsl<py.Literal>; 9 10export class LiteralPyDsl extends Mixed { 11 readonly '~dsl' = 'LiteralPyDsl'; 12 13 protected value: LiteralValue; 14 15 constructor(value: LiteralValue) { 16 super(); 17 this.value = value; 18 } 19 20 override analyze(_ctx: AnalysisContext): void { 21 super.analyze(_ctx); 22 } 23 24 override toAst(): py.Literal { 25 return py.factory.createLiteral(this.value); 26 } 27}