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.

refactor: add python playground

Lubos beb50aec 32edd131

+72 -50
+1
.gitignore
··· 24 24 25 25 # test files 26 26 .gen/ 27 + dev/gen/ 27 28 test/generated 28 29 29 30 # debug files
+1 -1
dev/openapi-python.config.ts
··· 14 14 path: './logs', 15 15 }, 16 16 output: { 17 - path: path.resolve(__dirname, '.gen', 'python'), 17 + path: path.resolve(__dirname, 'gen', 'python'), 18 18 }, 19 19 plugins: getPreset(), 20 20 },
+1 -1
dev/openapi-ts.config.ts
··· 14 14 path: './logs', 15 15 }, 16 16 output: { 17 - path: path.resolve(__dirname, '.gen', 'typescript'), 17 + path: path.resolve(__dirname, 'gen', 'typescript'), 18 18 }, 19 19 plugins: getPreset(), 20 20 },
+2 -1
dev/package.json
··· 4 4 "private": true, 5 5 "type": "module", 6 6 "scripts": { 7 - "dev": "ts-node ./playground.ts" 7 + "dev": "tsx ./playground.ts" 8 8 }, 9 9 "devDependencies": { 10 10 "@angular/common": "21.1.2", ··· 23 23 "arktype": "2.1.29", 24 24 "nuxt": "3.21.0", 25 25 "swr": "2.4.0", 26 + "tsx": "4.21.0", 26 27 "typescript": "5.9.3", 27 28 "valibot": "1.2.0", 28 29 "vue": "3.5.25",
+16
dev/playground.py
··· 1 + from gen.python import OpenCode 2 + 3 + 4 + def run(): 5 + client = OpenCode() 6 + client.tui.publish() 7 + # body={ 8 + # "properties": { 9 + # "message": "Hello from Hey API OpenAPI TS Playground!", 10 + # "variant": "success", 11 + # }, 12 + # "type": "tui.toast.show", 13 + # }, 14 + # directory="main", 15 + 16 + run()
+7 -3
dev/playground.ts
··· 1 1 import type { DefinePlugin, IR } from '@hey-api/openapi-ts'; 2 2 3 3 // import { createOpencode } from '@opencode-ai/sdk'; 4 - import { PetStore } from './.gen/typescript/sdk.gen.ts'; 4 + import { client } from './gen/typescript/client.gen'; 5 + import { OpenCode } from './gen/typescript/sdk.gen'; 5 6 6 7 type MyPluginConfig = { readonly name: 'myplugin' }; 7 8 type MyPlugin = DefinePlugin<MyPluginConfig>; ··· 19 20 async function run() { 20 21 // const { client, server } = await createOpencode(); 21 22 // console.log(client, server); 22 - const client = new PetStore(); 23 - client.tui.publish({ 23 + client.setConfig({ 24 + baseUrl: 'https://api.example.com', 25 + }); 26 + const sdk = new OpenCode({ client }); 27 + sdk.tui.publish({ 24 28 body: { 25 29 properties: { 26 30 message: 'Hello from Hey API OpenAPI TS Playground!',
+3 -7
dev/python/presets.ts
··· 5 5 sdk: () => [ 6 6 /** SDK */ 7 7 sdk({ 8 - '~hooks': { 9 - symbols: { 10 - // getExportFromFilePath(symbol) { 11 - // console.log(symbol.toString()); 12 - // return undefined; 13 - // }, 14 - }, 8 + operations: { 9 + containerName: 'OpenCode', 10 + strategy: 'single', 15 11 }, 16 12 }), 17 13 ],
+4 -5
dev/tsconfig.json
··· 1 1 { 2 - "extends": "../packages/openapi-ts-tests/tsconfig.base.json", 2 + "extends": "../tsconfig.base.json", 3 3 "compilerOptions": { 4 4 "allowImportingTsExtensions": true, 5 - "declaration": false, 6 - "esModuleInterop": true, 5 + "module": "ESNext", 6 + "moduleResolution": "bundler", 7 7 "noEmit": true, 8 - "resolveJsonModule": true, 9 - "skipLibCheck": true 8 + "resolveJsonModule": true 10 9 } 11 10 }
+1
dev/typescript/presets.ts
··· 22 22 containerName: 'OpenCode', 23 23 strategy: 'single', 24 24 }, 25 + paramsStructure: 'flat', 25 26 }), 26 27 ], 27 28 tanstack: () => [
-1
package.json
··· 70 70 "husky": "9.1.7", 71 71 "lint-staged": "16.2.7", 72 72 "oxfmt": "0.35.0", 73 - "ts-node": "10.9.2", 74 73 "tsdown": "0.18.4", 75 74 "tsx": "4.21.0", 76 75 "turbo": "2.8.12",
+3 -14
packages/openapi-python/src/plugins/@hey-api/sdk/v1/node.ts
··· 73 73 return [ 74 74 $.func(memberName) 75 75 .decorator(cachedProp) 76 + .param('self') 76 77 .returns(refChild) 77 78 .do( 78 79 $(refChild) ··· 115 116 }): T { 116 117 const { node, operation } = args; 117 118 118 - // Build the URL path 119 - const path = operation.path; 120 - 121 - // Get the HTTP method (default to GET) 122 119 const method = operation.method?.toLowerCase() || 'get'; 123 120 124 - // Create the client call expression: self.client.get(path) 125 - // self is the Python equivalent of 'this' for instance methods 126 - const selfExpr = $.id('self'); 127 - const clientExpr = $.attr(selfExpr, 'client'); 128 - const methodExpr = $.attr(clientExpr, method); 129 - const clientCall = $.call(methodExpr, $.literal(path)); 130 - 131 - // Return the client call 132 - node.do($.return(clientCall)); 121 + node.do($('self').attr('client').attr(method).call($.literal(operation.path)).return()); 133 122 134 123 return node; 135 124 } ··· 177 166 operation, 178 167 plugin, 179 168 }), 180 - ), 169 + ).param('self'), 181 170 operation, 182 171 plugin, 183 172 });
-1
packages/openapi-ts-tests/main/package.json
··· 40 40 "nuxt": "3.14.1592", 41 41 "ofetch": "1.5.1", 42 42 "rxjs": "7.8.2", 43 - "ts-node": "10.9.2", 44 43 "tslib": "2.8.1", 45 44 "typescript": "5.9.3", 46 45 "valibot": "1.2.0",
+4
packages/shared/src/plugins/shared/utils/instance.ts
··· 39 39 PluginInstanceTypes['Node'] 40 40 : Node; 41 41 42 + // TODO: abstract 42 43 const defaultGetFilePath = (symbol: Symbol): string | undefined => { 43 44 if (!symbol.meta?.pluginName || typeof symbol.meta.pluginName !== 'string') { 44 45 return; ··· 48 49 } 49 50 if (symbol.meta.pluginName === '@hey-api/typescript') { 50 51 return 'types'; 52 + } 53 + if (symbol.meta.pluginName === '@hey-api/python-sdk') { 54 + return 'sdk'; 51 55 } 52 56 if (symbol.meta.pluginName.startsWith('@hey-api/')) { 53 57 return symbol.meta.pluginName.split('/')[1];
+29 -16
pnpm-lock.yaml
··· 79 79 oxfmt: 80 80 specifier: 0.35.0 81 81 version: 0.35.0 82 - ts-node: 83 - specifier: 10.9.2 84 - version: 10.9.2(@types/node@24.10.10)(typescript@5.9.3) 85 82 tsdown: 86 83 specifier: 0.18.4 87 84 version: 0.18.4(@arethetypeswrong/core@0.18.2)(synckit@0.11.11)(typescript@5.9.3)(vue-tsc@3.2.4(typescript@5.9.3)) ··· 151 148 swr: 152 149 specifier: 2.4.0 153 150 version: 2.4.0(react@19.0.0) 151 + tsx: 152 + specifier: 4.21.0 153 + version: 4.21.0 154 154 typescript: 155 155 specifier: 5.9.3 156 156 version: 5.9.3 ··· 1495 1495 rxjs: 1496 1496 specifier: 7.8.2 1497 1497 version: 7.8.2 1498 - ts-node: 1499 - specifier: 10.9.2 1500 - version: 10.9.2(@types/node@25.2.1)(typescript@5.9.3) 1501 1498 tslib: 1502 1499 specifier: 2.8.1 1503 1500 version: 2.8.1 ··· 17207 17204 '@cspotcode/source-map-support@0.8.1': 17208 17205 dependencies: 17209 17206 '@jridgewell/trace-mapping': 0.3.9 17207 + optional: true 17210 17208 17211 17209 '@csstools/color-helpers@6.0.1': {} 17212 17210 ··· 18400 18398 dependencies: 18401 18399 '@jridgewell/resolve-uri': 3.1.2 18402 18400 '@jridgewell/sourcemap-codec': 1.5.5 18401 + optional: true 18403 18402 18404 18403 '@jsdevtools/ono@7.1.3': {} 18405 18404 ··· 21430 21429 vue: 3.5.25(typescript@5.9.3) 21431 21430 vue-demi: 0.14.10(vue@3.5.25(typescript@5.9.3)) 21432 21431 21433 - '@tsconfig/node10@1.0.11': {} 21432 + '@tsconfig/node10@1.0.11': 21433 + optional: true 21434 21434 21435 - '@tsconfig/node12@1.0.11': {} 21435 + '@tsconfig/node12@1.0.11': 21436 + optional: true 21436 21437 21437 - '@tsconfig/node14@1.0.3': {} 21438 + '@tsconfig/node14@1.0.3': 21439 + optional: true 21438 21440 21439 - '@tsconfig/node16@1.0.4': {} 21441 + '@tsconfig/node16@1.0.4': 21442 + optional: true 21440 21443 21441 21444 '@tsconfig/node24@24.0.4': {} 21442 21445 ··· 21602 21605 '@types/node@25.2.1': 21603 21606 dependencies: 21604 21607 undici-types: 7.16.0 21608 + optional: true 21605 21609 21606 21610 '@types/normalize-package-data@2.4.4': {} 21607 21611 ··· 22853 22857 acorn-walk@8.3.4: 22854 22858 dependencies: 22855 22859 acorn: 8.15.0 22860 + optional: true 22856 22861 22857 22862 acorn@7.4.1: {} 22858 22863 ··· 22970 22975 tar-stream: 3.1.7 22971 22976 zip-stream: 6.0.1 22972 22977 22973 - arg@4.1.3: {} 22978 + arg@4.1.3: 22979 + optional: true 22974 22980 22975 22981 arg@5.0.2: {} 22976 22982 ··· 23772 23778 crc-32: 1.2.2 23773 23779 readable-stream: 4.7.0 23774 23780 23775 - create-require@1.1.1: {} 23781 + create-require@1.1.1: 23782 + optional: true 23776 23783 23777 23784 cron-parser@4.9.0: 23778 23785 dependencies: ··· 24138 24145 24139 24146 didyoumean@1.2.2: {} 24140 24147 24141 - diff@4.0.2: {} 24148 + diff@4.0.2: 24149 + optional: true 24142 24150 24143 24151 diff@7.0.0: {} 24144 24152 ··· 26811 26819 dependencies: 26812 26820 semver: 7.7.3 26813 26821 26814 - make-error@1.3.6: {} 26822 + make-error@1.3.6: 26823 + optional: true 26815 26824 26816 26825 make-fetch-happen@15.0.3: 26817 26826 dependencies: ··· 30790 30799 typescript: 5.9.3 30791 30800 v8-compile-cache-lib: 3.0.1 30792 30801 yn: 3.1.1 30802 + optional: true 30793 30803 30794 30804 ts-node@10.9.2(@types/node@25.2.1)(typescript@5.9.3): 30795 30805 dependencies: ··· 30808 30818 typescript: 5.9.3 30809 30819 v8-compile-cache-lib: 3.0.1 30810 30820 yn: 3.1.1 30821 + optional: true 30811 30822 30812 30823 tsconfck@3.1.6(typescript@5.9.3): 30813 30824 optionalDependencies: ··· 31551 31562 31552 31563 uuid@8.3.2: {} 31553 31564 31554 - v8-compile-cache-lib@3.0.1: {} 31565 + v8-compile-cache-lib@3.0.1: 31566 + optional: true 31555 31567 31556 31568 valibot@1.2.0(typescript@5.9.3): 31557 31569 optionalDependencies: ··· 32562 32574 buffer-crc32: 0.2.13 32563 32575 fd-slicer: 1.1.0 32564 32576 32565 - yn@3.1.1: {} 32577 + yn@3.1.1: 32578 + optional: true 32566 32579 32567 32580 yocto-queue@0.1.0: {} 32568 32581