Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7023a42
feat(ofetch): init core client func & config
brolnickij Sep 14, 2025
ea0088a
feat(core): init `client-ofetch` support in plugin system
brolnickij Sep 14, 2025
aebfbdd
chore: init `ofetch` dep
brolnickij Sep 14, 2025
5305752
feat(build): add `client-ofetch` to `pluginNames`
brolnickij Sep 14, 2025
a1807fe
feat: initialize `ofetch` example project
brolnickij Sep 14, 2025
168e424
docs(ofetch): init
brolnickij Sep 14, 2025
9c5ef55
test(client-ofetch): add unit runtime tests
brolnickij Sep 14, 2025
ae42ac9
chore: bump `pnpm-lock.yaml`
brolnickij Sep 14, 2025
1aa9c2b
test(openapi-ts-tests): add `client-ofetch` to clients matrix & snaps…
brolnickij Sep 14, 2025
da9e05f
chore(release): add changeset for `client-ofetch`
brolnickij Sep 14, 2025
27695fa
chore: add `ofetch` to keywords in `package.json`
brolnickij Sep 14, 2025
a6f1681
chore: bump `ofetch` dependency
brolnickij Sep 14, 2025
5b4e24b
chore(ofetch): pin `vue` deps version
brolnickij Sep 14, 2025
cfd6dcf
chore(ofetch): update snapshots
brolnickij Sep 14, 2025
300f79a
docs(ofetch): init `SSE` section
brolnickij Sep 15, 2025
845318c
docs: cap of ofetch -> OFetch
brolnickij Sep 15, 2025
a37d0a3
docs(pinia-colada): add nuxt tips for compatibility
brolnickij Sep 15, 2025
9cf1458
chore(ofetch): enhance jsdoc for `Config` interface
brolnickij Sep 15, 2025
e1d6b27
chore(ofetch): cleanup comments
brolnickij Sep 15, 2025
43e59ff
chore: bump snapshots
brolnickij Sep 15, 2025
9793e70
fix(client-ofetch): keep error responses from throwing
brolnickij Sep 17, 2025
f8cb3fd
fix(client-ofetch): return `FormData` when `parseAs` is `formData`
brolnickij Sep 17, 2025
ef329e3
chore(client-ofetch): bump snapshots
brolnickij Sep 17, 2025
7322c67
docs: update client pages
mrlubos Sep 22, 2025
492a4e7
chore: fix types
mrlubos Sep 22, 2025
0e4a063
test: update snapshots
mrlubos Sep 22, 2025
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
5 changes: 5 additions & 0 deletions .changeset/init-ofetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

feat: add `ofetch` client available as `@hey-api/client-ofetch`
4 changes: 4 additions & 0 deletions docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ export default defineConfig({
link: '/openapi-ts/clients/nuxt',
text: 'Nuxt',
},
{
link: '/openapi-ts/clients/ofetch',
text: 'OFetch',
},
{
link: '/openapi-ts/clients/effect',
text: 'Effect <span data-soon>soon</span>',
Expand Down
1 change: 1 addition & 0 deletions docs/openapi-ts/clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Hey API natively supports the following clients.
- [Axios](/openapi-ts/clients/axios)
- [Next.js](/openapi-ts/clients/next-js)
- [Nuxt](/openapi-ts/clients/nuxt)
- [OFetch](/openapi-ts/clients/ofetch)
- [Effect](/openapi-ts/clients/effect) <span data-soon>Soon</span>
- [Legacy](/openapi-ts/clients/legacy)

Expand Down
6 changes: 3 additions & 3 deletions docs/openapi-ts/clients/angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ const url = client.buildUrl<FooData>({
console.log(url); // prints '/foo/1?bar=baz'
```

## Custom `httpClient`
## Custom Instance

You can implement your own `httpClient`. This is useful if you need to extend the default `httpClient` methods with extra functionality, or replace it altogether.
You can provide a custom `httpClient` instance. This is useful if you need to extend the default instance with extra functionality, or replace it altogether.

```js
import { client } from 'client/client.gen';
Expand All @@ -243,7 +243,7 @@ client.setConfig({
});
```

You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom client to be.
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom instance to be.

## Plugins

Expand Down
6 changes: 3 additions & 3 deletions docs/openapi-ts/clients/angular/v19.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ const url = client.buildUrl<FooData>({
console.log(url); // prints '/foo/1?bar=baz'
```

## Custom `httpClient`
## Custom Instance

You can implement your own `httpClient`. This is useful if you need to extend the default `httpClient` methods with extra functionality, or replace it altogether.
You can provide a custom `httpClient` instance. This is useful if you need to extend the default instance with extra functionality, or replace it altogether.

```js
import { client } from 'client/client.gen';
Expand All @@ -243,7 +243,7 @@ client.setConfig({
});
```

You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom client to be.
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom instance to be.

## Plugins

Expand Down
4 changes: 2 additions & 2 deletions docs/openapi-ts/clients/axios.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ const url = client.buildUrl<FooData>({
console.log(url); // prints '/foo/1?bar=baz'
```

## Custom `axios`
## Custom Instance

You can implement your own `axios` instance. This is useful if you need to extend the default `axios` instance with extra functionality, or replace it altogether.
You can provide a custom `axios` instance. This is useful if you need to extend the default instance with extra functionality, or replace it altogether.

```js
import axios from 'axios';
Expand Down
40 changes: 24 additions & 16 deletions docs/openapi-ts/clients/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,27 +146,32 @@ const response = await getFoo({

## Interceptors

Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to your application. They can be added with `use`, removed with `eject`, and updated wth `update`. The `use` and `update` methods will return the id of the interceptor for use with `eject` and `update`. Fetch API does not have the interceptor functionality, so we implement our own. Below is an example request interceptor
Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to your application.

They can be added with `use`, removed with `eject`, and updated wth `update`. The `use` and `update` methods will return the ID of the interceptor for use with `eject` and `update`. Fetch API does not have the interceptor functionality, so we implement our own.

### Example: Request interceptor

::: code-group

```js [use]
import { client } from 'client/client.gen';
// Supports async functions

async function myInterceptor(request) {
// do something
return request;
}

interceptorId = client.interceptors.request.use(myInterceptor);
```

```js [eject]
import { client } from 'client/client.gen';

// eject interceptor by interceptor id
// eject by ID
client.interceptors.request.eject(interceptorId);

// eject interceptor by reference to interceptor function
// eject by reference
client.interceptors.request.eject(myInterceptor);
```

Expand All @@ -177,36 +182,38 @@ async function myNewInterceptor(request) {
// do something
return request;
}
// update interceptor by interceptor id

// update by ID
client.interceptors.request.update(interceptorId, myNewInterceptor);

// update interceptor by reference to interceptor function
// update by reference
client.interceptors.request.update(myInterceptor, myNewInterceptor);
```

:::

and an example response interceptor
### Example: Response interceptor

::: code-group

```js [use]
import { client } from 'client/client.gen';

async function myInterceptor(response) {
// do something
return response;
}
// Supports async functions

interceptorId = client.interceptors.response.use(myInterceptor);
```

```js [eject]
import { client } from 'client/client.gen';

// eject interceptor by interceptor id
// eject by ID
client.interceptors.response.eject(interceptorId);

// eject interceptor by reference to interceptor function
// eject by reference
client.interceptors.response.eject(myInterceptor);
```

Expand All @@ -217,17 +224,18 @@ async function myNewInterceptor(response) {
// do something
return response;
}
// update interceptor by interceptor id

// update by ID
client.interceptors.response.update(interceptorId, myNewInterceptor);

// update interceptor by reference to interceptor function
// update by reference
client.interceptors.response.update(myInterceptor, myNewInterceptor);
```

:::

::: tip
To eject, you must provide the id or reference of the interceptor passed to `use()`, the id is the value returned by `use()` and `update()`.
To eject, you must provide the ID or reference of the interceptor passed to `use()`, the ID is the value returned by `use()` and `update()`.
:::

## Auth
Expand Down Expand Up @@ -281,9 +289,9 @@ const url = client.buildUrl<FooData>({
console.log(url); // prints '/foo/1?bar=baz'
```

## Custom `fetch`
## Custom Instance

You can implement your own `fetch` method. This is useful if you need to extend the default `fetch` method with extra functionality, or replace it altogether.
You can provide a custom `fetch` instance. This is useful if you need to extend the default instance with extra functionality, or replace it altogether.

```js
import { client } from 'client/client.gen';
Expand All @@ -295,7 +303,7 @@ client.setConfig({
});
```

You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom instance to be.

## API

Expand Down
40 changes: 24 additions & 16 deletions docs/openapi-ts/clients/next-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,32 @@ const response = await getFoo({

## Interceptors

Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to your application. They can be added with `use`, removed with `eject`, and updated wth `update`. The `use` and `update` methods will return the id of the interceptor for use with `eject` and `update`. Fetch API does not have the interceptor functionality, so we implement our own. Below is an example request interceptor
Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to your application.

They can be added with `use`, removed with `eject`, and updated wth `update`. The `use` and `update` methods will return the ID of the interceptor for use with `eject` and `update`. Fetch API does not have the interceptor functionality, so we implement our own.

### Example: Request interceptor

::: code-group

```js [use]
import { client } from 'client/client.gen';
// Supports async functions

async function myInterceptor(request) {
// do something
return request;
}

interceptorId = client.interceptors.request.use(myInterceptor);
```

```js [eject]
import { client } from 'client/client.gen';

// eject interceptor by interceptor id
// eject by ID
client.interceptors.request.eject(interceptorId);

// eject interceptor by reference to interceptor function
// eject by reference
client.interceptors.request.eject(myInterceptor);
```

Expand All @@ -161,36 +166,38 @@ async function myNewInterceptor(request) {
// do something
return request;
}
// update interceptor by interceptor id

// update by ID
client.interceptors.request.update(interceptorId, myNewInterceptor);

// update interceptor by reference to interceptor function
// update by reference
client.interceptors.request.update(myInterceptor, myNewInterceptor);
```

:::

and an example response interceptor
### Example: Response interceptor

::: code-group

```js [use]
import { client } from 'client/client.gen';

async function myInterceptor(response) {
// do something
return response;
}
// Supports async functions

interceptorId = client.interceptors.response.use(myInterceptor);
```

```js [eject]
import { client } from 'client/client.gen';

// eject interceptor by interceptor id
// eject by ID
client.interceptors.response.eject(interceptorId);

// eject interceptor by reference to interceptor function
// eject by reference
client.interceptors.response.eject(myInterceptor);
```

Expand All @@ -201,17 +208,18 @@ async function myNewInterceptor(response) {
// do something
return response;
}
// update interceptor by interceptor id

// update by ID
client.interceptors.response.update(interceptorId, myNewInterceptor);

// update interceptor by reference to interceptor function
// update by reference
client.interceptors.response.update(myInterceptor, myNewInterceptor);
```

:::

::: tip
To eject, you must provide the id or reference of the interceptor passed to `use()`, the id is the value returned by `use()` and `update()`.
To eject, you must provide the ID or reference of the interceptor passed to `use()`, the ID is the value returned by `use()` and `update()`.
:::

## Auth
Expand Down Expand Up @@ -264,9 +272,9 @@ const url = client.buildUrl<FooData>({
console.log(url); // prints '/foo/1?bar=baz'
```

## Custom `fetch`
## Custom Instance

You can implement your own `fetch` method. This is useful if you need to extend the default `fetch` method with extra functionality, or replace it altogether.
You can provide a custom `fetch` instance. This is useful if you need to extend the default instance with extra functionality, or replace it altogether.

```js
import { client } from 'client/client.gen';
Expand All @@ -278,7 +286,7 @@ client.setConfig({
});
```

You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom instance to be.

## API

Expand Down
6 changes: 3 additions & 3 deletions docs/openapi-ts/clients/nuxt.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ const url = client.buildUrl<FooData>({
console.log(url); // prints '/foo/1?bar=baz'
```

## Custom `$fetch`
## Custom Instance

You can implement your own `$fetch` method. This is useful if you need to extend the default `$fetch` method with extra functionality, or replace it altogether.
You can provide a custom `$fetch` instance. This is useful if you need to extend the default instance with extra functionality, or replace it altogether.

```js
import { client } from 'client/client.gen';
Expand All @@ -257,7 +257,7 @@ client.setConfig({
});
```

You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom method to be.
You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom instance to be.

## API

Expand Down
Loading
Loading