diff --git a/README.md b/README.md index 4574b138c..bbb84cb80 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ - [Quick Start](#quick-start) - [Installation](#installation) - [Configuration](#configuration) + - [Clients](#clients) - [Formatting](#formatting) - [Linting](#linting) - [Enums](#enums) @@ -96,6 +97,17 @@ export default { Alternatively, you can use `openapi-ts.config.js` and configure the export statement depending on your project setup. +### Clients + +We provide a variety of possible clients to use when generating your `openapi-ts` client. If one is not specified by the user, we will try to infer the client to use. If the inferred client is not correct, you can set it with the client config parameter. The following are available: + +- `angular`: An [Angular](https://angular.io/) client using [RxJS](https://rxjs.dev/). +- `axios`: An [Axios](https://axios-http.com/docs/intro) client. +- `fetch`: A [Fetch API](https://developer.mozilla.org/docs/Web/API/Fetch_API) client. + > NOTE: The Fetch API is experimental in Node.js 18+ and was stabilized in [Node.js v21](https://nodejs.org/docs/latest-v21.x/api/globals.html#fetch) +- `node`: A [Node.js](https://nodejs.org/) client using [node-fetch](https://www.npmjs.com/package/node-fetch). +- `xhr`: A [XMLHttpRequest](https://developer.mozilla.org/docs/Web/API/XMLHttpRequest) client. + ### Formatting By default, `openapi-ts` will automatically format your client according to your project configuration. To disable automatic formatting, set `format` to false diff --git a/test/bin.spec.ts b/test/bin.spec.ts index 2ad4d3872..234180a84 100755 --- a/test/bin.spec.ts +++ b/test/bin.spec.ts @@ -60,6 +60,7 @@ describe('bin', () => { expect(result.stdout.toString()).toContain(''); expect(result.stderr.toString()).toBe(''); }); + it('generates node client', async () => { const result = sync('node', [ './bin/index.js', diff --git a/test/e2e/scripts/generateClient.ts b/test/e2e/scripts/generateClient.ts index e3fd08644..c52e5eb5f 100644 --- a/test/e2e/scripts/generateClient.ts +++ b/test/e2e/scripts/generateClient.ts @@ -1,9 +1,10 @@ import { createClient } from '../../../'; +import type { Config } from '../../../src/types/config'; export const generateClient = async ( dir: string, version: string, - client: 'fetch' | 'xhr' | 'node' | 'axios' | 'angular', + client: Config['client'], useOptions: boolean = false, name?: string ) => {