From 3035e8035d46c98032a8328ae1d8ba5682e1f968 Mon Sep 17 00:00:00 2001 From: Jordan Shatford Date: Sat, 23 Mar 2024 15:53:31 +1100 Subject: [PATCH 1/2] chore(docs): add information about available clients --- README.md | 12 ++++++++++++ test/bin.spec.ts | 1 + test/e2e/scripts/generateClient.ts | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4574b138c..35dd836f9 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. 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/en-US/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/en-US/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 ) => { From 36544fd5ece4e2d22b23d750f9da8b1f44e61408 Mon Sep 17 00:00:00 2001 From: Jordan Shatford Date: Sat, 23 Mar 2024 20:45:20 +1100 Subject: [PATCH 2/2] chore(docs): address pr comments on client docs --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 35dd836f9..bbb84cb80 100644 --- a/README.md +++ b/README.md @@ -99,14 +99,14 @@ Alternatively, you can use `openapi-ts.config.js` and configure the export state ### Clients -We provide a variety of possible clients to use when generating your `openapi-ts` client. The following are available: +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/en-US/docs/Web/API/Fetch_API) 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/en-US/docs/Web/API/XMLHttpRequest) client. +- `xhr`: A [XMLHttpRequest](https://developer.mozilla.org/docs/Web/API/XMLHttpRequest) client. ### Formatting