Generated Client uses NodeJS exclusive Buffer API
See original GitHub issueDescribe the bug I create the client with the intent of using it in the Browser with the following options:
"scripts": {
"api:generate-client": "openapi --client axios --input ./src/api/openapi.yml --output ./src/api/client --useOptions --useUnionTypes && prettier --write src/api/client"
}
This generates a client that uses a NodeJS exclusive Buffer
API in the file core/request.ts
, which leads to a TS Error:
TS2580: Cannot find name 'Buffer'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`.
function base64(str: string): string {
try {
return btoa(str);
} catch (err) {
return Buffer.from(str).toString("base64"); // Buffer does not exist in Browser environments
}
}
Used Versions:
"devDependencies": {
...
"axios": "^0.24.0",
"cross-blob": "2.0.1",
"form-data": "4.0.0",
"openapi-typescript-codegen": "^0.12.5",
...
},
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Using Buffers in Node.js - DigitalOcean
A buffer is a space in memory (typically RAM) that stores binary data. In Node.js, we can access these spaces of memory with...
Read more >node/buffer.md at main - GitHub
The Buffer class is a subclass of JavaScript's Uint8Array class and extends it with methods that cover additional use cases. Node.js APIs accept...
Read more >Node.js v19.3.0 Documentation
Buffers and character encodings; Buffers and TypedArrays; Buffers and iteration; Class: Blob ... Usage; Node-API version matrix; Environment life cycle APIs.
Read more >Creating a Secure Node.js REST API - Toptal
In this article, Toptal JavaScript Developer Marcos Henrique da Silva shows how to create a simple and secure REST API for user management...
Read more >gRPC service in Node.js: Tutorial, Examples and Best practices
The client uses the protocol buffer to get a service and then connect to it ... It enables us to create gRPC service...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fantastic, thanks for the update @ferdikoomen
@wjdp @manuschillerdev There is a fix for this in the development branch now. Once i have fixed a few more issues i will push a new version to NPM