@kubb/plugin-client 5.0.0-beta.30 → 5.0.0-beta.33

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/src/types.ts CHANGED
@@ -171,12 +171,13 @@ export type Options = {
171
171
  paramsCasing?: 'camelcase'
172
172
  /**
173
173
  * Validator applied to response bodies before they are returned to the caller.
174
- * - `'client'` — no validation. Trusts the API.
174
+ * - `false` (default) — no validation. The client has no runtime parser; the response is
175
+ * returned as-is, cast to the generated TypeScript type.
175
176
  * - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
176
177
  *
177
- * @default 'client'
178
+ * @default false
178
179
  */
179
- parser?: 'client' | 'zod'
180
+ parser?: false | 'zod'
180
181
  /**
181
182
  * Shape of the generated client.
182
183
  * - `'function'` — one standalone async function per operation.
package/src/utils.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { getOperationParameters, resolveSuccessNames } from '@internals/shared'
1
+ import { getOperationParameters, getResponseType, resolveSuccessNames } from '@internals/shared'
2
2
  import type { URLPath } from '@internals/utils'
3
- import type { ast } from '@kubb/core'
3
+ import { ast } from '@kubb/core'
4
4
  import type { ResolverTs } from '@kubb/plugin-ts'
5
5
  import type { ResolverZod } from '@kubb/plugin-zod'
6
6
  import { createFunctionParams } from './functionParams.ts'
@@ -56,6 +56,7 @@ export function buildClassClientParams({
56
56
  const { query: queryParams } = getOperationParameters(node)
57
57
  const queryParamsName = queryParams.length > 0 ? tsResolver.resolveQueryParamsName(node, queryParams[0]!) : null
58
58
  const requestName = node.requestBody?.content?.[0]?.schema ? tsResolver.resolveDataName(node) : null
59
+ const responseType = getResponseType(node)
59
60
 
60
61
  return createFunctionParams({
61
62
  config: {
@@ -65,7 +66,7 @@ export function buildClassClientParams({
65
66
  mode: 'inlineSpread',
66
67
  },
67
68
  method: {
68
- value: JSON.stringify(node.method.toUpperCase()),
69
+ value: JSON.stringify(ast.isHttpOperationNode(node) ? node.method.toUpperCase() : ''),
69
70
  },
70
71
  url: {
71
72
  value: path.template,
@@ -87,6 +88,7 @@ export function buildClassClientParams({
87
88
  }
88
89
  : null,
89
90
  contentType: isMultipleContentTypes ? {} : null,
91
+ responseType: responseType ? { value: JSON.stringify(responseType) } : null,
90
92
  headers: headers.length
91
93
  ? {
92
94
  value: `{ ${headers.join(', ')}, ...requestConfig.headers }`,
@@ -150,7 +152,7 @@ export function buildReturnStatement({
150
152
  if (dataReturnType === 'data' && parser === 'zod' && zodResponseName) {
151
153
  return `return ${zodResponseName}.parse(res.data)`
152
154
  }
153
- if (dataReturnType === 'full' && parser === 'client') {
155
+ if (dataReturnType === 'full' && parser !== 'zod') {
154
156
  return 'return res'
155
157
  }
156
158
  return 'return res.data'