@kubb/plugin-axios 5.5.11 → 5.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1487,7 +1487,7 @@ var compatibility = {
1487
1487
  };
1488
1488
  //#endregion
1489
1489
  //#region package.json
1490
- var version = "5.5.11";
1490
+ var version = "5.5.13";
1491
1491
  //#endregion
1492
1492
  //#region src/templates.ts
1493
1493
  /** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
2
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
3
3
  import "kubb/jsx";
4
4
  import "@kubb/plugin-zod";
5
5
  //#region ../../internals/client/src/types.d.ts
@@ -188,7 +188,7 @@ type ResolvedOptions = {
188
188
  * resolved-options shape with the other client plugins; only the plugin name and transport
189
189
  * differ.
190
190
  */
191
- type PluginAxios = PluginFactoryOptions<'plugin-axios', Options, ResolvedOptions, ResolverClient>;
191
+ type PluginAxios = PluginType<'plugin-axios', Options, ResolvedOptions, ResolverClient>;
192
192
  declare global {
193
193
  namespace Kubb {
194
194
  interface PluginRegistry {
package/dist/index.js CHANGED
@@ -1461,7 +1461,7 @@ var compatibility = {
1461
1461
  };
1462
1462
  //#endregion
1463
1463
  //#region package.json
1464
- var version = "5.5.11";
1464
+ var version = "5.5.13";
1465
1465
  //#endregion
1466
1466
  //#region src/templates.ts
1467
1467
  /** Absolute path to the axios client template, copied into `.kubb/client.ts`. */
@@ -70,8 +70,3 @@ const { data } = await getPetById({ path: { petId: 1 }, client: tenant })
70
70
  To override the client for one request, pass `auth` on that single call, which suits a one-off token refresh. An explicit `headers` value you set on a call always wins over the resolved token.
71
71
 
72
72
  For authentication outside OpenAPI security schemes, use an async request interceptor to sign requests or supply custom headers.
73
-
74
- ## See also
75
-
76
- - [Add interceptors](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/interceptors)
77
- - [Set the base URL](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/base-url)
@@ -56,8 +56,3 @@ const { data } = await getPetById({ path: { petId: 1 }, baseURL: 'https://localh
56
56
  ```
57
57
 
58
58
  A `baseURL` set on the call wins over `createClient`, which wins over `setConfig`, which wins over the build-time value.
59
-
60
- ## See also
61
-
62
- - [Authenticate requests](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/authentication)
63
- - [Use a custom transport](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/transport)
@@ -138,10 +138,3 @@ const url = client.getUrl({
138
138
  })
139
139
  // https://api.example.com/v1/pets/1?fields=name
140
140
  ```
141
-
142
- ## See also
143
-
144
- - [Handle errors](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/error-handling)
145
- - [Configure serialization](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/serialization)
146
- - [Set the base URL](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/base-url)
147
- - [Server-sent events](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/server-sent-events)
@@ -116,9 +116,3 @@ A `ParseError` reports schema validation issues. A `ResponseError` reports a non
116
116
 
117
117
  Calling `.unwrap()` on a `throwOnError: false` call turns that same `error` into a rejection, so a
118
118
  `try`/`catch` works there too.
119
-
120
- ## See also
121
-
122
- - [Call operations](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/calling-operations)
123
- - [Configure serialization](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/serialization)
124
- - [Add interceptors](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/interceptors)
@@ -74,9 +74,3 @@ Interceptors registered through `client.interceptors` also follow a custom trans
74
74
  instance and attach to the new one, and their IDs stay valid for `eject` and `update`. Clearing the
75
75
  transport (`client.setConfig({ transport: undefined })`) moves them back to the client's base
76
76
  instance. A per-call `transport` still bypasses client interceptors.
77
-
78
- ## See also
79
-
80
- - [Handle errors](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/error-handling)
81
- - [Authenticate requests](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/authentication)
82
- - [Use a custom transport](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/transport)
@@ -112,9 +112,3 @@ pluginAxios({ validator: { request: 'zod', response: 'zod' } })
112
112
  With a validator set, Kubb passes the matching schema to each generated call, and the runtime
113
113
  parses the body through it. A body that does not match throws a `ParseError` with the schema's
114
114
  `issues`.
115
-
116
- ## See also
117
-
118
- - [Call operations](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/calling-operations)
119
- - [Handle errors](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/error-handling)
120
- - [Server-sent events](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/server-sent-events)
@@ -92,8 +92,3 @@ try {
92
92
  > [!NOTE]
93
93
  > A drop mid-stream ends the `for await` loop. Track the last event's `id` if you need to reconnect
94
94
  > from where the stream stopped.
95
-
96
- ## See also
97
-
98
- - [Call operations](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/calling-operations)
99
- - [Handle errors](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/error-handling)
@@ -42,9 +42,3 @@ Every generated function now sends through your instance, so its timeout, header
42
42
  ## Where to set it
43
43
 
44
44
  Use `client.setConfig({ transport })` for shared configuration, `createClient({ transport })` for an isolated instance, or pass `transport` on an operation to override it for one call.
45
-
46
- ## See also
47
-
48
- - [Add interceptors](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/interceptors)
49
- - [Set the base URL](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/base-url)
50
- - [Call operations](https://kubb.dev/extensions/kubb-labs/plugin-axios/guides/calling-operations)
package/docs/options.md CHANGED
@@ -11,7 +11,6 @@ Pass these options to `pluginAxios()`. Shared options link to [Shared plugin opt
11
11
  | [`baseURL`](#baseurl) | Base URL prepended to every request. | None |
12
12
  | [`throwOnErrorDefault`](#throwonerrordefault) | Default error behavior and return type for generated operations. | `true` |
13
13
  | [`validator`](#validator) | Validate request and response bodies with Zod. | `false` |
14
- | [`comments`](#comments) | How much of each description reaches the JSDoc. | `'full'` |
15
14
  | [`sdk`](#sdk) | Emit a class-based SDK instead of standalone functions. | None |
16
15
  | [`returnType`](#returntype) | Shape of the value a generated call resolves to. | `'full'` |
17
16
  | [`include`](https://kubb.dev/docs/5.x/reference/plugin-options#include) | Keep only operations that match. | None |
@@ -90,32 +89,6 @@ export default defineConfig({
90
89
  })
91
90
  ```
92
91
 
93
- ### comments
94
-
95
- Controls generated JSDoc.
96
-
97
- | | |
98
- | -------- | ----------------------------- |
99
- | Type | `'full' \| 'brief' \| 'none'` |
100
- | Required | `false` |
101
- | Default | `'full'` |
102
-
103
- ::field-group
104
-
105
- :::field{name="'full'"}
106
- Default value. Keeps complete descriptions and tags.
107
- :::
108
-
109
- :::field{name="'brief'"}
110
- Keeps the first sentence and other tags. Descriptions over 150 characters without a sentence ending are cut at the last word before 120.
111
- :::
112
-
113
- :::field{name="'none'"}
114
- Omits JSDoc but keeps the generated-by banner.
115
- :::
116
-
117
- ::
118
-
119
92
  ### sdk
120
93
 
121
94
  Generates a class-based SDK. Each instance takes its own client config, so environments can use separate clients. Leave `sdk` unset to keep the standalone functions that query plugins call.
package/docs/overview.md CHANGED
@@ -1,25 +1,29 @@
1
1
  # Axios
2
2
 
3
- Generates a type-safe HTTP client based on axios from your OpenAPI spec. Each operation becomes one async function with grouped `path`, `query`, `headers`, and `body` parameters and a result keyed by status code.
3
+ The Axios plugin turns each operation in your OpenAPI spec into a typed async function that sends the request with axios. Each function takes grouped `path`, `query`, `headers`, and `body` parameters and returns a result keyed by status code.
4
4
 
5
- This plugin provides the client runtime. Query plugins such as `@kubb/plugin-react-query`, `@kubb/plugin-vue-query`, `@kubb/plugin-swr`, and `@kubb/plugin-mcp` call the functions it generates.
5
+ The query plugins (`@kubb/plugin-react-query`, `@kubb/plugin-vue-query`, and `@kubb/plugin-swr`) and `@kubb/plugin-mcp` call these functions. The plugin also copies its runtime files (`client.ts`, `serializers.ts`, and `standardSchema.ts`) to `.kubb/` in the root output folder.
6
6
 
7
7
  ## Setup
8
8
 
9
- - Add `@kubb/plugin-ts` for the operation types. Without it, `@kubb/plugin-zod` with `inferred: true` supplies them.
10
- - Add `@kubb/plugin-zod` when you set `validator`.
11
- - Install axios v1 or higher in the app that uses the generated code.
9
+ - Add `@kubb/plugin-ts` for the operation types, or `@kubb/plugin-zod` with `inferred: true`.
10
+ - Add `@kubb/plugin-zod` when you set `validator`, and install `zod` v4. Without the plugin, `validator` does nothing.
11
+ - Install `axios` 1.20 or a later v1 release in the app that uses the generated code.
12
12
 
13
13
  ## Options worth knowing
14
14
 
15
- - `baseURL` is prepended to every request.
16
- - `validator: 'zod'` validates request and response bodies with the schemas from `@kubb/plugin-zod`.
17
- - `sdk` generates a class-based SDK, grouped by tag or flat, instead of standalone functions. Query plugins need the standalone functions, so leave `sdk` unset when you use them.
18
- - `returnType: 'data'` makes a call resolve to the success body instead of the full result with status, data, and error.
19
- - `throwOnErrorDefault: false` returns documented error responses as values instead of throwing. A single call can still pass `throwOnError`.
15
+ - `baseURL` is prepended to every request. The spec's `servers` URL is not used, so without `baseURL` you set one at runtime with `client.setConfig({ baseURL })`.
16
+ - `validator: 'zod'` validates response bodies with the schemas from `@kubb/plugin-zod`. Use `{ request: 'zod', response: 'zod' }` to also validate request bodies.
17
+ - `throwOnErrorDefault: false` returns non-2xx responses as values instead of throwing. A single call can still pass `throwOnError`.
18
+ - `returnType: 'data'` makes a call resolve to the success body instead of the full result. With `throwOnError: false`, the call still returns the full result.
19
+ - `sdk` generates a class-based SDK, grouped by tag or flat, instead of standalone functions. The query plugins and `@kubb/plugin-mcp` need the standalone functions, so leave `sdk` unset when you use them.
20
+
21
+ See [Options](https://kubb.dev/extensions/kubb-labs/plugin-axios/options) for every option and its default.
20
22
 
21
23
  ## Example
22
24
 
25
+ The config below generates an axios client that sends every request to the Petstore API.
26
+
23
27
  ```typescript [kubb.config.ts]
24
28
  import { defineConfig } from 'kubb/config'
25
29
  import { pluginTs } from '@kubb/plugin-ts'
@@ -34,8 +38,3 @@ export default defineConfig({
34
38
  ],
35
39
  })
36
40
  ```
37
-
38
- ## See also
39
-
40
- - [axios](https://axios-http.com/)
41
- - [`@kubb/plugin-ts`](https://kubb.dev/extensions/kubb-labs/plugin-ts)
@@ -18,6 +18,7 @@
18
18
  }
19
19
  ],
20
20
  "dependencies": ["plugin-ts"],
21
+ "optionalDependencies": ["plugin-zod"],
21
22
  "compatibility": {
22
23
  "kubb": ">=5.8.3",
23
24
  "node": ">=22"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-axios",
3
- "version": "5.5.11",
3
+ "version": "5.5.13",
4
4
  "description": "Generate a slim, type-safe HTTP client with Kubb based on axios.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -68,19 +68,19 @@
68
68
  "registry": "https://registry.npmjs.org/"
69
69
  },
70
70
  "dependencies": {
71
- "@kubb/plugin-ts": "^5.0.9",
72
- "@kubb/plugin-zod": "^5.4.7"
71
+ "@kubb/plugin-ts": "^5.0.11",
72
+ "@kubb/plugin-zod": "^5.4.9"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@internals/client": "0.0.0",
76
76
  "@internals/shared": "0.0.0",
77
77
  "axios": "^1.20.0",
78
- "kubb": "^5.8.3",
78
+ "kubb": "^5.9.2",
79
79
  "typescript": "^6.0.3"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "axios": "^1.20.0",
83
- "kubb": "^5.8.3"
83
+ "kubb": "^5.9.2"
84
84
  },
85
85
  "peerDependenciesMeta": {
86
86
  "axios": {
package/src/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PluginFactoryOptions } from 'kubb/kit'
1
+ import type { PluginType } from 'kubb/kit'
2
2
  import type { Options, ResolvedOptions, ResolverClient } from '@internals/client'
3
3
 
4
4
  export type { Options, ResolvedOptions, ResolverClient } from '@internals/client'
@@ -8,7 +8,7 @@ export type { Options, ResolvedOptions, ResolverClient } from '@internals/client
8
8
  * resolved-options shape with the other client plugins; only the plugin name and transport
9
9
  * differ.
10
10
  */
11
- export type PluginAxios = PluginFactoryOptions<'plugin-axios', Options, ResolvedOptions, ResolverClient>
11
+ export type PluginAxios = PluginType<'plugin-axios', Options, ResolvedOptions, ResolverClient>
12
12
 
13
13
  declare global {
14
14
  namespace Kubb {