@orpc/openapi 1.14.9 → 1.14.11

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.
Files changed (48) hide show
  1. package/README.md +52 -71
  2. package/dist/adapters/fetch/index.d.mts +20 -16
  3. package/dist/adapters/fetch/index.d.ts +20 -16
  4. package/dist/adapters/fetch/index.mjs +24 -8
  5. package/dist/adapters/node/index.d.mts +8 -13
  6. package/dist/adapters/node/index.d.ts +8 -13
  7. package/dist/adapters/node/index.mjs +10 -7
  8. package/dist/adapters/standard/index.d.mts +46 -16
  9. package/dist/adapters/standard/index.d.ts +46 -16
  10. package/dist/adapters/standard/index.mjs +9 -6
  11. package/dist/extensions/route.d.mts +43 -0
  12. package/dist/extensions/route.d.ts +43 -0
  13. package/dist/extensions/route.mjs +14 -0
  14. package/dist/helpers/index.d.mts +51 -0
  15. package/dist/helpers/index.d.ts +51 -0
  16. package/dist/helpers/index.mjs +39 -0
  17. package/dist/index.d.mts +117 -105
  18. package/dist/index.d.ts +117 -105
  19. package/dist/index.mjs +850 -32
  20. package/dist/plugins/index.d.mts +55 -51
  21. package/dist/plugins/index.d.ts +55 -51
  22. package/dist/plugins/index.mjs +147 -142
  23. package/dist/shared/openapi.B6hEbRyF.d.ts +83 -0
  24. package/dist/shared/openapi.B9PQzqBn.mjs +49 -0
  25. package/dist/shared/openapi.BOOA-bde.d.mts +142 -0
  26. package/dist/shared/openapi.BOOA-bde.d.ts +142 -0
  27. package/dist/shared/openapi.BafbB3uM.d.mts +83 -0
  28. package/dist/shared/openapi.Bt87OzTt.mjs +131 -0
  29. package/dist/shared/openapi.ByT4oUeY.d.mts +18 -0
  30. package/dist/shared/openapi.ByT4oUeY.d.ts +18 -0
  31. package/dist/shared/openapi.C-p_Q2lb.mjs +359 -0
  32. package/dist/shared/openapi.CVgUshDP.mjs +318 -0
  33. package/dist/shared/openapi.DNNo0V-l.d.ts +313 -0
  34. package/dist/shared/openapi.hg_rhZ4x.d.mts +313 -0
  35. package/dist/shared/openapi.zZH_UksW.mjs +278 -0
  36. package/package.json +46 -24
  37. package/dist/adapters/aws-lambda/index.d.mts +0 -20
  38. package/dist/adapters/aws-lambda/index.d.ts +0 -20
  39. package/dist/adapters/aws-lambda/index.mjs +0 -18
  40. package/dist/adapters/fastify/index.d.mts +0 -23
  41. package/dist/adapters/fastify/index.d.ts +0 -23
  42. package/dist/adapters/fastify/index.mjs +0 -18
  43. package/dist/shared/openapi.BB-W-NKv.mjs +0 -204
  44. package/dist/shared/openapi.BGy4N6eR.d.mts +0 -120
  45. package/dist/shared/openapi.BGy4N6eR.d.ts +0 -120
  46. package/dist/shared/openapi.BwdtJjDu.mjs +0 -878
  47. package/dist/shared/openapi.DwaweYRb.d.mts +0 -54
  48. package/dist/shared/openapi.DwaweYRb.d.ts +0 -54
@@ -0,0 +1,313 @@
1
+ import { AnySchema, ErrorMap, MetaPlugin, AnyProcedureContract } from '@orpc/contract';
2
+ import { Lazy } from '@orpc/server';
3
+ import { Value } from '@orpc/shared';
4
+ import { StandardBodyHint } from '@standardserver/core';
5
+ import { O as OpenAPIOperationObject } from './openapi.ByT4oUeY.js';
6
+
7
+ interface OpenAPIMeta {
8
+ /**
9
+ * HTTP method accepted by this procedure.
10
+ *
11
+ * @default 'POST'
12
+ */
13
+ method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | undefined;
14
+ /**
15
+ * URL path for this procedure. Supports dynamic parameters via `{param}` syntax,
16
+ * and `{+param}` to allow slashes in the matched value.
17
+ *
18
+ * @example `/users`, `/users/{id}`, `/files/{+path}`
19
+ * @default Router segments joined by `'/`
20
+ */
21
+ path?: `/${string}` | undefined;
22
+ /**
23
+ * Unique identifier for this operation in the OpenAPI spec.
24
+ *
25
+ * @default Router segments joined by `.`
26
+ */
27
+ operationId?: string | undefined;
28
+ /**
29
+ * Short summary of the procedure, used as the operation summary in the generated spec.
30
+ */
31
+ summary?: string | undefined;
32
+ /**
33
+ * Detailed description of the procedure, used as the operation description in the generated spec.
34
+ */
35
+ description?: string | undefined;
36
+ /**
37
+ * Marks the procedure as deprecated in the generated spec.
38
+ */
39
+ deprecated?: boolean | undefined;
40
+ /**
41
+ * Tags associated with this procedure.
42
+ *
43
+ * **Merging**: When defined multiple times, tags are concatenated in definition order.
44
+ * Explicitly setting `undefined` resets the tags instead of merging.
45
+ */
46
+ tags?: string[] | undefined;
47
+ /**
48
+ * HTTP status code returned on success.
49
+ * Should be in the `2xx` range and must be less than `400`.
50
+ *
51
+ * @default 200
52
+ */
53
+ successStatus?: number | undefined;
54
+ /**
55
+ * Description of the successful response.
56
+ *
57
+ * @default 'OK'
58
+ */
59
+ successDescription?: string | undefined;
60
+ /**
61
+ * Controls how individual path parameters are decoded.
62
+ *
63
+ * **Merging**: When defined multiple times, styles are merged per parameter.
64
+ * The most recent style defined for a parameter wins.
65
+ * Explicitly setting `undefined` resets the styles instead of merging.
66
+ *
67
+ * Each key maps a path parameter name to one of the following strategies:
68
+ *
69
+ * | Strategy | Encoded path segment | Decoded | OpenAPI Parameter Style |
70
+ * |--------------------------|----------------------|------------------------------|----------------------------------|
71
+ * | `primitive` *(default)* | `/users/42` | `{ id: '42' }` | `simple` |
72
+ * | `comma-delimited-array` | `/users/a,b,c` | `{ id: ['a', 'b', 'c'] }` | `simple` |
73
+ * | `comma-delimited-object` | `/users/a,1,b,2` | `{ id: { a: '1', b: '2' } }` | `simple` |
74
+ *
75
+ * **Strategy details:**
76
+ *
77
+ * - **`primitive`**: Keeps the decoded path segment as a string.
78
+ * - **`comma-delimited-array`**: Splits the decoded path segment on `,` into an array.
79
+ * - **`comma-delimited-object`**: Splits the decoded path segment on `,` into alternating key-value pairs.
80
+ *
81
+ * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * // openapi.path = '/users/{id}/{tags}/{filters}'
86
+ * // GET /users/42/red,blue/size,large,brand,nike
87
+ *
88
+ * const paramsStyles = {
89
+ * id: 'primitive',
90
+ * tags: 'comma-delimited-array',
91
+ * filters: 'comma-delimited-object',
92
+ * }
93
+ *
94
+ * const inputSchema = z.object({
95
+ * id: z.string(),
96
+ * tags: z.array(z.string()),
97
+ * filters: z.object({
98
+ * size: z.string(),
99
+ * brand: z.string(),
100
+ * }),
101
+ * })
102
+ * ```
103
+ *
104
+ * @default `primitive` for all parameters
105
+ */
106
+ paramsStyles?: Record<string, 'primitive' | 'comma-delimited-array' | 'comma-delimited-object' | undefined> | undefined;
107
+ /**
108
+ * Controls how individual query parameters are encoding/decoding.
109
+ *
110
+ * **Merging**: When defined multiple times, styles are merged per parameter.
111
+ * The most recent style defined for a parameter wins.
112
+ * Explicitly setting `undefined` resets the styles instead of merging.
113
+ *
114
+ * Each key maps a query parameter name to one of the following strategies:
115
+ *
116
+ * | Strategy | Encoded | Decoded | OpenAPI Parameter Style |
117
+ * |--------------------------|---------------------------|--------------------------------|------------------------------------|
118
+ * | `primitive` | `?a=1&a=2` | `{ a: '2' }` | `form` / `explode: false` |
119
+ * | `array` | `?a=1&a=2` | `{ a: ['1', '2'] }` | `form` / `explode: true` |
120
+ * | `comma-delimited-array` | `?a=1,2,3` | `{ a: ['1', '2', '3'] }` | `form` / `explode: false` |
121
+ * | `comma-delimited-object` | `?a=A,1,B,2` | `{ a: { A: '1', B: '2' } }` | `form` / `explode: false` |
122
+ * | `space-delimited-array` | `?a=1 2 3` | `{ a: ['1', '2', '3'] }` | `spaceDelimited` / `explode: false`|
123
+ * | `space-delimited-object` | `?a=A 1 B 2` | `{ a: { A: '1', B: '2' } }` | `spaceDelimited` / `explode: false`|
124
+ * | `pipe-delimited-array` | `?a=1\|2\|3` | `{ a: ['1', '2', '3'] }` | `pipeDelimited` / `explode: false` |
125
+ * | `pipe-delimited-object` | `?a=A\|1\|B\|2` | `{ a: { A: '1', B: '2' } }` | `pipeDelimited` / `explode: false` |
126
+ * | `json` | `?meta={"key":"value"}` | `{ meta: { key: 'value' } }` | `content: application/json` |
127
+ * | _default_ | `?a[]=1&a[]=2&b=3&c[d]=4` | `{a:['1', '2'], b:3, c:{d:4}}` | `deepObject` / `explode: true` |
128
+ *
129
+ * **Strategy details:**
130
+ *
131
+ * - **`primitive`**: Takes the last occurrence of a repeated parameter.
132
+ * - **`array`**: Always produces an array, even for a single occurrence.
133
+ * - **`*-delimited-array`**: Splits the last value on the delimiter (`,`, space, or `|`) into an array.
134
+ * - **`*-delimited-object`**: Splits the last value on the delimiter into alternating key–value pairs.
135
+ * - **`json`**: Parses the last value as JSON; falls back to the raw string if parsing fails.
136
+ * - **`undefined`**: Standard bracket-notation decoding This is the default.
137
+ *
138
+ * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * // GET /search?keyword=abc&tags=a,b,c&meta={"key":"value"}
143
+ * const queryParsing = {
144
+ * keyword: 'primitive',
145
+ * tags: 'comma-delimited-array',
146
+ * meta: 'json',
147
+ * }
148
+ *
149
+ * const inputSchema = z.object({
150
+ * keyword: z.string(),
151
+ * tags: z.array(z.string()),
152
+ * meta: z.object({ key: z.string() }),
153
+ * })
154
+ * ```
155
+ *
156
+ * @default `undefined` for all parameters (bracket-notation decoding)
157
+ */
158
+ queryStyles?: Record<string, 'primitive' | 'array' | 'comma-delimited-array' | 'comma-delimited-object' | 'space-delimited-array' | 'space-delimited-object' | 'pipe-delimited-array' | 'pipe-delimited-object' | 'json' | undefined> | undefined;
159
+ /**
160
+ * Hint for how to parse the incoming request body.
161
+ *
162
+ * Note: The `standard-server` `Content-Type` header takes priority over this option.
163
+ * `form-data` and `url-search-params` are decoded using bracket notation,
164
+ * so the resulting value will be an object or array.
165
+ *
166
+ * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
167
+ */
168
+ requestBodyHint?: StandardBodyHint | undefined;
169
+ /**
170
+ * Hint for how to parse the response body.
171
+ *
172
+ * Note: The `standard-server` `Content-Type` header takes priority over this option.
173
+ * `form-data` and `url-search-params` are decoded using bracket notation,
174
+ * so the resulting value will be an object or array.
175
+ *
176
+ * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
177
+ */
178
+ responseBodyHint?: StandardBodyHint | undefined;
179
+ /**
180
+ * Determines how the input should be structured
181
+ * based on params, query, headers, and body.
182
+ *
183
+ * - `compact` — Merges params with either query or body
184
+ * (depending on the HTTP method) into a single flat object.
185
+ * Use this when you don't need access to headers and your
186
+ * param/query/body keys don't conflict.
187
+ *
188
+ * ```ts
189
+ * // GET /users/42?search=hello
190
+ * const inputValue = { id: 42, search: 'hello' }
191
+ *
192
+ * const inputSchema = z.object({
193
+ * id: z.coerce.number(), // from params
194
+ * search: z.string(), // from query
195
+ * })
196
+ * ```
197
+ *
198
+ * - `detailed` — Keeps each part of the request as a
199
+ * separate nested field. Use this when you need access
200
+ * to headers, or when params and query/body keys
201
+ * might conflict.
202
+ *
203
+ * ```ts
204
+ * const inputValue = {
205
+ * params: { id: 1 },
206
+ * query: { search: 'hello' },
207
+ * headers: { 'content-type': 'application/json' },
208
+ * body: 'body value',
209
+ * }
210
+ *
211
+ * const inputSchema = z.object({
212
+ * params: z.object({ id: z.coerce.number() }),
213
+ * query: z.object({ search: z.string() }),
214
+ * headers: z.object({ 'content-type': z.string() }),
215
+ * body: z.string(),
216
+ * })
217
+ * ```
218
+ *
219
+ * @default 'compact'
220
+ */
221
+ inputStructure?: 'compact' | 'detailed' | undefined;
222
+ /**
223
+ * Determines how the output should be structured
224
+ * into the HTTP response.
225
+ *
226
+ * - `compact` — The return value is sent directly as the
227
+ * response body. Status code comes from successStatus.
228
+ *
229
+ * ```ts
230
+ * const outputValue = { id: 1, name: 'Alice' }
231
+ *
232
+ * const outputSchema = z.object({
233
+ * id: z.number(),
234
+ * name: z.string(),
235
+ * })
236
+ * ```
237
+ *
238
+ * - `detailed` — Return an object with optional properties:
239
+ * - status: HTTP status code (200–399). Defaults to
240
+ * successStatus if omitted. Use a literal type
241
+ * (e.g. z.literal(201)) so the generated spec can reflects
242
+ * the exact code.
243
+ * - headers: Custom headers to merge into the response
244
+ * (Record<string, string | string[] | undefined>).
245
+ * - body: The response body.
246
+ *
247
+ * ```ts
248
+ * const outputValue = {
249
+ * status: 201,
250
+ * headers: { 'x-custom-header': 'value' },
251
+ * body: 'body value',
252
+ * }
253
+ *
254
+ * const outputSchema = z.object({
255
+ * status: z.literal(201).meta({ description: 'Record Created' }),
256
+ * headers: z.object({ 'x-custom-header': z.string() }),
257
+ * body: z.string(),
258
+ * })
259
+ * ```
260
+ *
261
+ * @default 'compact'
262
+ */
263
+ outputStructure?: 'compact' | 'detailed' | undefined;
264
+ /**
265
+ * Override or extend the generated OpenAPI operation object for this procedure.
266
+ *
267
+ * Pass a plain object to replace entire operation object, or a function that receives the current
268
+ * operation object and returns the modified version.
269
+ *
270
+ * **Merging**: When defined multiple times:
271
+ *
272
+ * - Two functions are chained: the most recent function receives the result of the previous one.
273
+ * - A function combined with an object: the function is applied to that object.
274
+ * - Two objects: the most recent object wins.
275
+ *
276
+ * Explicitly setting `undefined` resets the spec instead of merging.
277
+ */
278
+ spec?: Value<OpenAPIOperationObject, [current: OpenAPIOperationObject]>;
279
+ /**
280
+ * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
281
+ *
282
+ * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
283
+ * Explicitly setting `undefined` resets the prefix instead of merging.
284
+ */
285
+ prefix?: `/${string}` | undefined;
286
+ }
287
+ interface OpenAPIMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
288
+ name: '~openapi';
289
+ }
290
+ interface OpenAPIMethodMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
291
+ name: '~openapi/method';
292
+ }
293
+ interface OpenAPIPathMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
294
+ name: '~openapi/path';
295
+ }
296
+ interface OpenAPISpecMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
297
+ name: '~openapi/spec';
298
+ }
299
+ interface OpenAPIPrefixMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
300
+ name: '~openapi/prefix';
301
+ }
302
+ interface OpenAPIFunction {
303
+ (meta: OpenAPIMeta): OpenAPIMetaPlugin<any, any, any>;
304
+ method(method: OpenAPIMeta['method']): OpenAPIMethodMetaPlugin<any, any, any>;
305
+ path(method: OpenAPIMeta['path']): OpenAPIPathMetaPlugin<any, any, any>;
306
+ spec(method: OpenAPIMeta['spec']): OpenAPISpecMetaPlugin<any, any, any>;
307
+ prefix(method: OpenAPIMeta['prefix']): OpenAPIPrefixMetaPlugin<any, any, any>;
308
+ }
309
+ declare const openapi: OpenAPIFunction;
310
+ declare function getOpenAPIMeta(procedureOrLazy: AnyProcedureContract | Lazy<any>): OpenAPIMeta | undefined;
311
+
312
+ export { getOpenAPIMeta as g, openapi as o };
313
+ export type { OpenAPIMeta as O, OpenAPIFunction as a, OpenAPIMetaPlugin as b, OpenAPIMethodMetaPlugin as c, OpenAPIPathMetaPlugin as d, OpenAPIPrefixMetaPlugin as e, OpenAPISpecMetaPlugin as f };
@@ -0,0 +1,313 @@
1
+ import { AnySchema, ErrorMap, MetaPlugin, AnyProcedureContract } from '@orpc/contract';
2
+ import { Lazy } from '@orpc/server';
3
+ import { Value } from '@orpc/shared';
4
+ import { StandardBodyHint } from '@standardserver/core';
5
+ import { O as OpenAPIOperationObject } from './openapi.ByT4oUeY.mjs';
6
+
7
+ interface OpenAPIMeta {
8
+ /**
9
+ * HTTP method accepted by this procedure.
10
+ *
11
+ * @default 'POST'
12
+ */
13
+ method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | undefined;
14
+ /**
15
+ * URL path for this procedure. Supports dynamic parameters via `{param}` syntax,
16
+ * and `{+param}` to allow slashes in the matched value.
17
+ *
18
+ * @example `/users`, `/users/{id}`, `/files/{+path}`
19
+ * @default Router segments joined by `'/`
20
+ */
21
+ path?: `/${string}` | undefined;
22
+ /**
23
+ * Unique identifier for this operation in the OpenAPI spec.
24
+ *
25
+ * @default Router segments joined by `.`
26
+ */
27
+ operationId?: string | undefined;
28
+ /**
29
+ * Short summary of the procedure, used as the operation summary in the generated spec.
30
+ */
31
+ summary?: string | undefined;
32
+ /**
33
+ * Detailed description of the procedure, used as the operation description in the generated spec.
34
+ */
35
+ description?: string | undefined;
36
+ /**
37
+ * Marks the procedure as deprecated in the generated spec.
38
+ */
39
+ deprecated?: boolean | undefined;
40
+ /**
41
+ * Tags associated with this procedure.
42
+ *
43
+ * **Merging**: When defined multiple times, tags are concatenated in definition order.
44
+ * Explicitly setting `undefined` resets the tags instead of merging.
45
+ */
46
+ tags?: string[] | undefined;
47
+ /**
48
+ * HTTP status code returned on success.
49
+ * Should be in the `2xx` range and must be less than `400`.
50
+ *
51
+ * @default 200
52
+ */
53
+ successStatus?: number | undefined;
54
+ /**
55
+ * Description of the successful response.
56
+ *
57
+ * @default 'OK'
58
+ */
59
+ successDescription?: string | undefined;
60
+ /**
61
+ * Controls how individual path parameters are decoded.
62
+ *
63
+ * **Merging**: When defined multiple times, styles are merged per parameter.
64
+ * The most recent style defined for a parameter wins.
65
+ * Explicitly setting `undefined` resets the styles instead of merging.
66
+ *
67
+ * Each key maps a path parameter name to one of the following strategies:
68
+ *
69
+ * | Strategy | Encoded path segment | Decoded | OpenAPI Parameter Style |
70
+ * |--------------------------|----------------------|------------------------------|----------------------------------|
71
+ * | `primitive` *(default)* | `/users/42` | `{ id: '42' }` | `simple` |
72
+ * | `comma-delimited-array` | `/users/a,b,c` | `{ id: ['a', 'b', 'c'] }` | `simple` |
73
+ * | `comma-delimited-object` | `/users/a,1,b,2` | `{ id: { a: '1', b: '2' } }` | `simple` |
74
+ *
75
+ * **Strategy details:**
76
+ *
77
+ * - **`primitive`**: Keeps the decoded path segment as a string.
78
+ * - **`comma-delimited-array`**: Splits the decoded path segment on `,` into an array.
79
+ * - **`comma-delimited-object`**: Splits the decoded path segment on `,` into alternating key-value pairs.
80
+ *
81
+ * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * // openapi.path = '/users/{id}/{tags}/{filters}'
86
+ * // GET /users/42/red,blue/size,large,brand,nike
87
+ *
88
+ * const paramsStyles = {
89
+ * id: 'primitive',
90
+ * tags: 'comma-delimited-array',
91
+ * filters: 'comma-delimited-object',
92
+ * }
93
+ *
94
+ * const inputSchema = z.object({
95
+ * id: z.string(),
96
+ * tags: z.array(z.string()),
97
+ * filters: z.object({
98
+ * size: z.string(),
99
+ * brand: z.string(),
100
+ * }),
101
+ * })
102
+ * ```
103
+ *
104
+ * @default `primitive` for all parameters
105
+ */
106
+ paramsStyles?: Record<string, 'primitive' | 'comma-delimited-array' | 'comma-delimited-object' | undefined> | undefined;
107
+ /**
108
+ * Controls how individual query parameters are encoding/decoding.
109
+ *
110
+ * **Merging**: When defined multiple times, styles are merged per parameter.
111
+ * The most recent style defined for a parameter wins.
112
+ * Explicitly setting `undefined` resets the styles instead of merging.
113
+ *
114
+ * Each key maps a query parameter name to one of the following strategies:
115
+ *
116
+ * | Strategy | Encoded | Decoded | OpenAPI Parameter Style |
117
+ * |--------------------------|---------------------------|--------------------------------|------------------------------------|
118
+ * | `primitive` | `?a=1&a=2` | `{ a: '2' }` | `form` / `explode: false` |
119
+ * | `array` | `?a=1&a=2` | `{ a: ['1', '2'] }` | `form` / `explode: true` |
120
+ * | `comma-delimited-array` | `?a=1,2,3` | `{ a: ['1', '2', '3'] }` | `form` / `explode: false` |
121
+ * | `comma-delimited-object` | `?a=A,1,B,2` | `{ a: { A: '1', B: '2' } }` | `form` / `explode: false` |
122
+ * | `space-delimited-array` | `?a=1 2 3` | `{ a: ['1', '2', '3'] }` | `spaceDelimited` / `explode: false`|
123
+ * | `space-delimited-object` | `?a=A 1 B 2` | `{ a: { A: '1', B: '2' } }` | `spaceDelimited` / `explode: false`|
124
+ * | `pipe-delimited-array` | `?a=1\|2\|3` | `{ a: ['1', '2', '3'] }` | `pipeDelimited` / `explode: false` |
125
+ * | `pipe-delimited-object` | `?a=A\|1\|B\|2` | `{ a: { A: '1', B: '2' } }` | `pipeDelimited` / `explode: false` |
126
+ * | `json` | `?meta={"key":"value"}` | `{ meta: { key: 'value' } }` | `content: application/json` |
127
+ * | _default_ | `?a[]=1&a[]=2&b=3&c[d]=4` | `{a:['1', '2'], b:3, c:{d:4}}` | `deepObject` / `explode: true` |
128
+ *
129
+ * **Strategy details:**
130
+ *
131
+ * - **`primitive`**: Takes the last occurrence of a repeated parameter.
132
+ * - **`array`**: Always produces an array, even for a single occurrence.
133
+ * - **`*-delimited-array`**: Splits the last value on the delimiter (`,`, space, or `|`) into an array.
134
+ * - **`*-delimited-object`**: Splits the last value on the delimiter into alternating key–value pairs.
135
+ * - **`json`**: Parses the last value as JSON; falls back to the raw string if parsing fails.
136
+ * - **`undefined`**: Standard bracket-notation decoding This is the default.
137
+ *
138
+ * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * // GET /search?keyword=abc&tags=a,b,c&meta={"key":"value"}
143
+ * const queryParsing = {
144
+ * keyword: 'primitive',
145
+ * tags: 'comma-delimited-array',
146
+ * meta: 'json',
147
+ * }
148
+ *
149
+ * const inputSchema = z.object({
150
+ * keyword: z.string(),
151
+ * tags: z.array(z.string()),
152
+ * meta: z.object({ key: z.string() }),
153
+ * })
154
+ * ```
155
+ *
156
+ * @default `undefined` for all parameters (bracket-notation decoding)
157
+ */
158
+ queryStyles?: Record<string, 'primitive' | 'array' | 'comma-delimited-array' | 'comma-delimited-object' | 'space-delimited-array' | 'space-delimited-object' | 'pipe-delimited-array' | 'pipe-delimited-object' | 'json' | undefined> | undefined;
159
+ /**
160
+ * Hint for how to parse the incoming request body.
161
+ *
162
+ * Note: The `standard-server` `Content-Type` header takes priority over this option.
163
+ * `form-data` and `url-search-params` are decoded using bracket notation,
164
+ * so the resulting value will be an object or array.
165
+ *
166
+ * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
167
+ */
168
+ requestBodyHint?: StandardBodyHint | undefined;
169
+ /**
170
+ * Hint for how to parse the response body.
171
+ *
172
+ * Note: The `standard-server` `Content-Type` header takes priority over this option.
173
+ * `form-data` and `url-search-params` are decoded using bracket notation,
174
+ * so the resulting value will be an object or array.
175
+ *
176
+ * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
177
+ */
178
+ responseBodyHint?: StandardBodyHint | undefined;
179
+ /**
180
+ * Determines how the input should be structured
181
+ * based on params, query, headers, and body.
182
+ *
183
+ * - `compact` — Merges params with either query or body
184
+ * (depending on the HTTP method) into a single flat object.
185
+ * Use this when you don't need access to headers and your
186
+ * param/query/body keys don't conflict.
187
+ *
188
+ * ```ts
189
+ * // GET /users/42?search=hello
190
+ * const inputValue = { id: 42, search: 'hello' }
191
+ *
192
+ * const inputSchema = z.object({
193
+ * id: z.coerce.number(), // from params
194
+ * search: z.string(), // from query
195
+ * })
196
+ * ```
197
+ *
198
+ * - `detailed` — Keeps each part of the request as a
199
+ * separate nested field. Use this when you need access
200
+ * to headers, or when params and query/body keys
201
+ * might conflict.
202
+ *
203
+ * ```ts
204
+ * const inputValue = {
205
+ * params: { id: 1 },
206
+ * query: { search: 'hello' },
207
+ * headers: { 'content-type': 'application/json' },
208
+ * body: 'body value',
209
+ * }
210
+ *
211
+ * const inputSchema = z.object({
212
+ * params: z.object({ id: z.coerce.number() }),
213
+ * query: z.object({ search: z.string() }),
214
+ * headers: z.object({ 'content-type': z.string() }),
215
+ * body: z.string(),
216
+ * })
217
+ * ```
218
+ *
219
+ * @default 'compact'
220
+ */
221
+ inputStructure?: 'compact' | 'detailed' | undefined;
222
+ /**
223
+ * Determines how the output should be structured
224
+ * into the HTTP response.
225
+ *
226
+ * - `compact` — The return value is sent directly as the
227
+ * response body. Status code comes from successStatus.
228
+ *
229
+ * ```ts
230
+ * const outputValue = { id: 1, name: 'Alice' }
231
+ *
232
+ * const outputSchema = z.object({
233
+ * id: z.number(),
234
+ * name: z.string(),
235
+ * })
236
+ * ```
237
+ *
238
+ * - `detailed` — Return an object with optional properties:
239
+ * - status: HTTP status code (200–399). Defaults to
240
+ * successStatus if omitted. Use a literal type
241
+ * (e.g. z.literal(201)) so the generated spec can reflects
242
+ * the exact code.
243
+ * - headers: Custom headers to merge into the response
244
+ * (Record<string, string | string[] | undefined>).
245
+ * - body: The response body.
246
+ *
247
+ * ```ts
248
+ * const outputValue = {
249
+ * status: 201,
250
+ * headers: { 'x-custom-header': 'value' },
251
+ * body: 'body value',
252
+ * }
253
+ *
254
+ * const outputSchema = z.object({
255
+ * status: z.literal(201).meta({ description: 'Record Created' }),
256
+ * headers: z.object({ 'x-custom-header': z.string() }),
257
+ * body: z.string(),
258
+ * })
259
+ * ```
260
+ *
261
+ * @default 'compact'
262
+ */
263
+ outputStructure?: 'compact' | 'detailed' | undefined;
264
+ /**
265
+ * Override or extend the generated OpenAPI operation object for this procedure.
266
+ *
267
+ * Pass a plain object to replace entire operation object, or a function that receives the current
268
+ * operation object and returns the modified version.
269
+ *
270
+ * **Merging**: When defined multiple times:
271
+ *
272
+ * - Two functions are chained: the most recent function receives the result of the previous one.
273
+ * - A function combined with an object: the function is applied to that object.
274
+ * - Two objects: the most recent object wins.
275
+ *
276
+ * Explicitly setting `undefined` resets the spec instead of merging.
277
+ */
278
+ spec?: Value<OpenAPIOperationObject, [current: OpenAPIOperationObject]>;
279
+ /**
280
+ * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
281
+ *
282
+ * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
283
+ * Explicitly setting `undefined` resets the prefix instead of merging.
284
+ */
285
+ prefix?: `/${string}` | undefined;
286
+ }
287
+ interface OpenAPIMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
288
+ name: '~openapi';
289
+ }
290
+ interface OpenAPIMethodMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
291
+ name: '~openapi/method';
292
+ }
293
+ interface OpenAPIPathMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
294
+ name: '~openapi/path';
295
+ }
296
+ interface OpenAPISpecMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
297
+ name: '~openapi/spec';
298
+ }
299
+ interface OpenAPIPrefixMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
300
+ name: '~openapi/prefix';
301
+ }
302
+ interface OpenAPIFunction {
303
+ (meta: OpenAPIMeta): OpenAPIMetaPlugin<any, any, any>;
304
+ method(method: OpenAPIMeta['method']): OpenAPIMethodMetaPlugin<any, any, any>;
305
+ path(method: OpenAPIMeta['path']): OpenAPIPathMetaPlugin<any, any, any>;
306
+ spec(method: OpenAPIMeta['spec']): OpenAPISpecMetaPlugin<any, any, any>;
307
+ prefix(method: OpenAPIMeta['prefix']): OpenAPIPrefixMetaPlugin<any, any, any>;
308
+ }
309
+ declare const openapi: OpenAPIFunction;
310
+ declare function getOpenAPIMeta(procedureOrLazy: AnyProcedureContract | Lazy<any>): OpenAPIMeta | undefined;
311
+
312
+ export { getOpenAPIMeta as g, openapi as o };
313
+ export type { OpenAPIMeta as O, OpenAPIFunction as a, OpenAPIMetaPlugin as b, OpenAPIMethodMetaPlugin as c, OpenAPIPathMetaPlugin as d, OpenAPIPrefixMetaPlugin as e, OpenAPISpecMetaPlugin as f };