Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): add information about available clients #130

Merged
merged 2 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Configuration](#configuration)
- [Clients](#clients)
- [Formatting](#formatting)
- [Linting](#linting)
- [Enums](#enums)
Expand Down Expand Up @@ -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/).
jordanshatford marked this conversation as resolved.
Show resolved Hide resolved
- `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
Expand Down
1 change: 1 addition & 0 deletions test/bin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion test/e2e/scripts/generateClient.ts
Original file line number Diff line number Diff line change
@@ -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
) => {
Expand Down