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.

at feat/use-query-options 36 lines 932 B view raw
1import type { NodeName } from '@hey-api/codegen-core'; 2 3import { py } from '../../py-compiler'; 4import type { MaybePyDsl } from '../base'; 5import { PyDsl } from '../base'; 6 7export type KwargValue = string | number | boolean | null | MaybePyDsl<py.Expression>; 8 9export class KwargPyDsl extends PyDsl<py.KeywordArgument> { 10 readonly '~dsl' = 'KwargPyDsl'; 11 12 protected _value: KwargValue; 13 14 constructor(name: NodeName, value: KwargValue) { 15 super(); 16 this.name.set(name); 17 this._value = value; 18 } 19 20 override toAst() { 21 const name = this.name.toString(); 22 return py.factory.createKeywordArgument(name, this.$valueToNode(this._value)); 23 } 24 25 private $valueToNode(value: KwargValue) { 26 if ( 27 typeof value === 'string' || 28 typeof value === 'number' || 29 typeof value === 'boolean' || 30 value === null 31 ) { 32 return py.factory.createLiteral(value); 33 } 34 return this.$node(value); 35 } 36}