OpenAPITools / OpenAPITools/openapi-generator
[REQ] [Typescript] Use `node:` Prefix-Only For Core Modules
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Hi, I'm using the typescript generator with the deno platform.
Deno is now fully node compatible, but since some node native objects are imported implicitly, the generated code results in some errors.
For instance, Buffer is used in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache#L88 without any import, and Deno can't resolve it.
error: Uncaught (in promise) ReferenceError: Buffer is not defined
let comb = Buffer.from(this.username + ":" + this.password, 'binary').toString('base64');
^
at BasicAuthAuthentication.applySecurityAuthentication (file:///home/project/auth/auth.ts:65:20)
Describe the solution you'd like
The solution is as easy as :
import { Buffer } from "node:buffer";
Disclaimer : this feature was introduced in node 18.
Describe alternatives you've considered
Use web API compliant code to encode to base64.
Additional context
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/openapi-generator/src/main/resources/typescript/auth/auth.mustache and inspect the TypeScript generator templates for other implicit Node core-module usage. Check how generated Deno clients handle these imports, then verify that the affected generated code uses node:-prefixed imports and no longer raises the reported Buffer error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- deno, node.js, typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100