Skip to content

Commit

Permalink
Integrate within 1 command
Browse files Browse the repository at this point in the history
  • Loading branch information
dqbd committed Mar 5, 2023
1 parent ba505ce commit df06be4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules

.DS_Store
*.log
5 changes: 5 additions & 0 deletions scripts/generate_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion scripts/override_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

/**
Expand Down

0 comments on commit df06be4

Please sign in to comment.