Proposal to swap deprecated request for node-fetch
Request is fully deprecated requiring us to switch libraries (see #414 for more information).
@brendanburns outlined some of the clear options forward. This change should ideally be a long-term solution leaving us with the option of either modifying the node-typescript open-api-generator to use a different request library or migrate to one of the other generator options.
Modifying an outdated node-typescript library does not seem like the right path forward. It would require us to still use a new library which would likely change the api and still be a breaking change. We might as well migrate to a newer version of openapi-generator while we do that and acquire the advantages of a more up-to-date version.
Choosing a new library
@d-cs posted a nice summary of the different choices. We narrowed it down to Axios or Fetch. The other libraries didn't match how widely adopted and focused these libraries are.
Fetch is simply the standard JavaScript as a whole is moving to, which brings more longterm support aligning us better with our goal of migrating to a long-term solution. node-fetch has significantly more weekly downloads than axios. The package size of node-fetch is also noticeably smaller than axios.
Additionally, future improvements could likely be done to allow us to also support the browser #165 since Fetch is native to the browser.
Node-fetch
Fetch is a native browser API that is not implemented in Node.js by default. Node-fetch is the natural choice for the Node implementation because it is the most widely adopted.
The openapi-generator uses the browser implementation of Fetch so we must substitute node-fetch in manually.
Implementation steps
@davidgamero and I will work to implement the following changes.
Other repositories
Kubernetes-client repository
import fetch from 'node-fetch';
// inject node-fetch
if (!globalThis.fetch) {
// @ts-ignore
globalThis.fetch = fetch;
globalThis.Headers = Headers;
globalThis.Request = Request;
globalThis.Response = Response;
}
Proposal to swap deprecated request for node-fetch
Request is fully deprecated requiring us to switch libraries (see #414 for more information).
@brendanburns outlined some of the clear options forward. This change should ideally be a long-term solution leaving us with the option of either modifying the node-typescript open-api-generator to use a different request library or migrate to one of the other generator options.
Modifying an outdated node-typescript library does not seem like the right path forward. It would require us to still use a new library which would likely change the api and still be a breaking change. We might as well migrate to a newer version of openapi-generator while we do that and acquire the advantages of a more up-to-date version.
Choosing a new library
@d-cs posted a nice summary of the different choices. We narrowed it down to Axios or Fetch. The other libraries didn't match how widely adopted and focused these libraries are.
Fetch is simply the standard JavaScript as a whole is moving to, which brings more longterm support aligning us better with our goal of migrating to a long-term solution. node-fetch has significantly more weekly downloads than axios. The package size of node-fetch is also noticeably smaller than axios.
Additionally, future improvements could likely be done to allow us to also support the browser #165 since Fetch is native to the browser.
Node-fetch
Fetch is a native browser API that is not implemented in Node.js by default. Node-fetch is the natural choice for the Node implementation because it is the most widely adopted.
The openapi-generator uses the browser implementation of Fetch so we must substitute node-fetch in manually.
Implementation steps
@davidgamero and I will work to implement the following changes.
Other repositories
typescriptThreePlusconfig option 1 2Kubernetes-client repository
OPENAPI_GENERATOR_COMMITto be version 5.3.0npm install node-fetchto install node-fetchsrc/api.tswith the followingnpm run generate