diff --git a/.gitignore b/.gitignore index 5f58e4c0..1c3e58b2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules - +.DS_Store *.log \ No newline at end of file diff --git a/scripts/generate_sdk.py b/scripts/generate_sdk.py index 78d2c8be..554ce4a6 100644 --- a/scripts/generate_sdk.py +++ b/scripts/generate_sdk.py @@ -86,8 +86,13 @@ def generate_sdk(sanitized_spec_path, sdk_type, output_path): if sdk_type == "node": template_override_path = os.path.join(os.path.dirname( __file__), "../sdk-template-overrides/typescript-axios") + stream_ast = os.path.join(os.path.dirname(__file__), "./override_stream.ts") + data_source = os.path.join(output_path, "./**/*{.d.ts,.ts}") + os.system( f"openapi-generator generate -i {sanitized_spec_path} -g typescript-axios -o {output_path} -p supportsES6=true -t {template_override_path}") + + os.system(f"npx tsx '{stream_ast}' '{data_source}'") else: print(f"Unsupported SDK type {sdk_type}, skipping SDK generation") diff --git a/scripts/override_stream.ts b/scripts/override_stream.ts index 20914126..84ff4e2e 100644 --- a/scripts/override_stream.ts +++ b/scripts/override_stream.ts @@ -148,7 +148,7 @@ function transformClass(sourceNode: Node) { } const project = new Project(); -project.addSourceFilesAtPaths("openai-node/**/*{.d.ts,.ts}"); +project.addSourceFilesAtPaths(process.argv[process.argv.length - 1]); const sourceFile = project.getSourceFileOrThrow("api.ts"); const declarations = sourceFile.getExportedDeclarations(); diff --git a/sdk-template-overrides/typescript-axios/configuration.mustache b/sdk-template-overrides/typescript-axios/configuration.mustache index 1020f66b..ed9a87b8 100644 --- a/sdk-template-overrides/typescript-axios/configuration.mustache +++ b/sdk-template-overrides/typescript-axios/configuration.mustache @@ -99,9 +99,6 @@ export class Configuration { if (this.organization) { this.baseOptions.headers['OpenAI-Organization'] = this.organization; } - if (!this.formDataCtor) { - this.formDataCtor = require("form-data"); - } } /**