-
-
Notifications
You must be signed in to change notification settings - Fork 528
Node‐Fetch Support
By default, this tool will generate a client that is compatible with the (browser based) Fetch API.
However, this client will not work inside the Node.js environment. If you want to generate the Node.js compatible
client then you can specify --client node
in the openapi call:
openapi --input ./spec.json --output ./generated --client node
This will generate a client that uses node-fetch
internally. However,
in order to compile and run this client, you might need to install the [email protected]
dependencies.
Since version 3.x
node-fetch
switched to ESM only, breaking many CommonJS based toolchains (like Jest). Right now we do not support this new version!
npm install @types/[email protected] --save-dev
npm install [email protected] --save-dev
npm install [email protected] --save-dev
npm install [email protected] --save-dev
In order to compile the project and resolve the imports, you will need to enable the allowSyntheticDefaultImports
in your tsconfig.json
file.