@orpc/openapi 2.0.0-beta.49 → 2.0.0-beta.50

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 (65) hide show
  1. package/dist/adapters/aws-lambda/index.d.ts +3 -15
  2. package/dist/adapters/aws-lambda/index.js +1 -1
  3. package/dist/adapters/aws-lambda/openapi-handler.d.ts +8 -9
  4. package/dist/adapters/aws-lambda/openapi-handler.js +19 -17
  5. package/dist/adapters/fastify/index.d.ts +2 -1
  6. package/dist/adapters/fastify/index.js +1 -1
  7. package/dist/adapters/fastify/openapi-handler.d.ts +8 -9
  8. package/dist/adapters/fastify/openapi-handler.js +16 -14
  9. package/dist/adapters/fetch/index.d.ts +3 -2
  10. package/dist/adapters/fetch/index.js +2 -2
  11. package/dist/adapters/fetch/openapi-handler.d.ts +8 -9
  12. package/dist/adapters/fetch/openapi-handler.js +16 -14
  13. package/dist/adapters/fetch/openapi-link.d.ts +9 -10
  14. package/dist/adapters/fetch/openapi-link.js +21 -19
  15. package/dist/adapters/node/index.d.ts +2 -1
  16. package/dist/adapters/node/index.js +1 -1
  17. package/dist/adapters/node/openapi-handler.d.ts +8 -9
  18. package/dist/adapters/node/openapi-handler.js +16 -14
  19. package/dist/adapters/standard/index.d.ts +4 -3
  20. package/dist/adapters/standard/index.js +3 -3
  21. package/dist/adapters/standard/openapi-handler-codec.d.ts +56 -57
  22. package/dist/adapters/standard/openapi-handler-codec.js +143 -205
  23. package/dist/adapters/standard/openapi-link-codec.d.ts +55 -59
  24. package/dist/adapters/standard/openapi-link-codec.js +262 -377
  25. package/dist/adapters/standard/openapi-matcher.d.ts +26 -26
  26. package/dist/adapters/standard/openapi-matcher.js +78 -108
  27. package/dist/adapters/standard/utils.js +28 -44
  28. package/dist/bracket-notation.d.ts +22 -22
  29. package/dist/bracket-notation.js +123 -173
  30. package/dist/client-factory.d.ts +12 -12
  31. package/dist/client-factory.js +13 -11
  32. package/dist/constants.d.ts +1 -4
  33. package/dist/constants.js +5 -4
  34. package/dist/extensions/route.d.ts +36 -36
  35. package/dist/extensions/route.js +7 -6
  36. package/dist/helpers/form-data.d.ts +1 -1
  37. package/dist/helpers/form-data.js +74 -86
  38. package/dist/helpers/index.d.ts +2 -1
  39. package/dist/helpers/index.js +1 -1
  40. package/dist/index.d.ts +15 -13
  41. package/dist/index.js +11 -11
  42. package/dist/meta.d.ts +298 -298
  43. package/dist/meta.js +54 -72
  44. package/dist/openapi-generator-components.d.ts +2 -31
  45. package/dist/openapi-generator-components.js +200 -248
  46. package/dist/openapi-generator-operation.d.ts +12 -33
  47. package/dist/openapi-generator-operation.js +369 -437
  48. package/dist/openapi-generator.d.ts +75 -80
  49. package/dist/openapi-generator.js +114 -142
  50. package/dist/openapi-json-serializer.d.ts +65 -65
  51. package/dist/openapi-json-serializer.js +218 -257
  52. package/dist/openapi-serializer.d.ts +31 -32
  53. package/dist/openapi-serializer.js +68 -92
  54. package/dist/plugins/index.d.ts +2 -1
  55. package/dist/plugins/index.js +1 -1
  56. package/dist/plugins/openapi-reference.d.ts +99 -102
  57. package/dist/plugins/openapi-reference.js +109 -132
  58. package/dist/router-utils.d.ts +7 -10
  59. package/dist/router-utils.js +30 -34
  60. package/dist/types.d.ts +8 -12
  61. package/dist/utils.d.ts +5 -10
  62. package/dist/utils.js +39 -42
  63. package/package.json +12 -12
  64. package/dist/adapters/standard/utils.d.ts +0 -4
  65. package/dist/types.js +0 -1
package/dist/meta.d.ts CHANGED
@@ -1,313 +1,313 @@
1
- import type { AnyProcedureContract, AnySchema, ErrorMap, MetaPlugin } from '@orpc/contract';
2
- import type { Lazy } from '@orpc/server';
3
- import type { Value } from '@orpc/shared';
4
- import type { StandardBodyHint } from '@standard-server/core';
5
- import type { OpenAPIV3_2 } from './types.ts';
1
+ import { OpenAPIV3_2 } from "./types.js";
2
+ import { Value } from "@orpc/shared";
3
+ import { AnyProcedureContract, AnySchema, ErrorMap, MetaPlugin } from "@orpc/contract";
4
+ import { Lazy } from "@orpc/server";
5
+ import { StandardBodyHint } from "@standard-server/core";
6
6
  export interface OpenAPIMeta {
7
- /**
8
- * HTTP method accepted by this procedure.
9
- *
10
- * @default 'POST'
11
- */
12
- method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'QUERY' | undefined;
13
- /**
14
- * URL path for this procedure. Supports dynamic parameters via `{param}` syntax,
15
- * and `{+param}` to allow slashes in the matched value.
16
- *
17
- * @example `/users`, `/users/{id}`, `/files/{+path}`
18
- * @default Router segments joined by `'/`
19
- */
20
- path?: `/${string}` | undefined;
21
- /**
22
- * Unique identifier for this operation in the OpenAPI spec.
23
- *
24
- * @default Router segments joined by `.`
25
- */
26
- operationId?: string | undefined;
27
- /**
28
- * Short summary of the procedure, used as the operation summary in the generated spec.
29
- */
30
- summary?: string | undefined;
31
- /**
32
- * Detailed description of the procedure, used as the operation description in the generated spec.
33
- */
34
- description?: string | undefined;
35
- /**
36
- * Marks the procedure as deprecated in the generated spec.
37
- */
38
- deprecated?: boolean | undefined;
39
- /**
40
- * Tags associated with this procedure.
41
- *
42
- * **Merging**: When defined multiple times, tags are concatenated in definition order.
43
- * Explicitly setting `undefined` resets the tags instead of merging.
44
- */
45
- tags?: string[] | undefined;
46
- /**
47
- * HTTP status code returned on success.
48
- * Should be in the `2xx` range and must be less than `400`.
49
- *
50
- * @default 200
51
- */
52
- successStatus?: number | undefined;
53
- /**
54
- * Description of the successful response.
55
- *
56
- * @default 'OK'
57
- */
58
- successDescription?: string | undefined;
59
- /**
60
- * Controls how individual path parameters are decoded.
61
- *
62
- * **Merging**: When defined multiple times, styles are merged per parameter.
63
- * The most recent style defined for a parameter wins.
64
- * Explicitly setting `undefined` resets the styles instead of merging.
65
- *
66
- * Each key maps a path parameter name to one of the following strategies:
67
- *
68
- * | Strategy | Encoded path segment | Decoded | OpenAPI Parameter Style |
69
- * |--------------------------|----------------------|------------------------------|----------------------------------|
70
- * | `primitive` *(default)* | `/users/42` | `{ id: '42' }` | `simple` |
71
- * | `comma-delimited-array` | `/users/a,b,c` | `{ id: ['a', 'b', 'c'] }` | `simple` |
72
- * | `comma-delimited-object` | `/users/a,1,b,2` | `{ id: { a: '1', b: '2' } }` | `simple` |
73
- *
74
- * **Strategy details:**
75
- *
76
- * - **`primitive`**: Keeps the decoded path segment as a string.
77
- * - **`comma-delimited-array`**: Splits the decoded path segment on `,` into an array.
78
- * - **`comma-delimited-object`**: Splits the decoded path segment on `,` into alternating key-value pairs.
79
- *
80
- * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
81
- *
82
- * @example
83
- * ```ts
84
- * // openapi.path = '/users/{id}/{tags}/{filters}'
85
- * // GET /users/42/red,blue/size,large,brand,nike
86
- *
87
- * const paramsStyles = {
88
- * id: 'primitive',
89
- * tags: 'comma-delimited-array',
90
- * filters: 'comma-delimited-object',
91
- * }
92
- *
93
- * const inputSchema = z.object({
94
- * id: z.string(),
95
- * tags: z.array(z.string()),
96
- * filters: z.object({
97
- * size: z.string(),
98
- * brand: z.string(),
99
- * }),
100
- * })
101
- * ```
102
- *
103
- * @default `primitive` for all parameters
104
- */
105
- paramsStyles?: Record<string, 'primitive' | 'comma-delimited-array' | 'comma-delimited-object' | undefined> | undefined;
106
- /**
107
- * Controls how individual query parameters are encoding/decoding.
108
- *
109
- * **Merging**: When defined multiple times, styles are merged per parameter.
110
- * The most recent style defined for a parameter wins.
111
- * Explicitly setting `undefined` resets the styles instead of merging.
112
- *
113
- * Each key maps a query parameter name to one of the following strategies:
114
- *
115
- * | Strategy | Encoded | Decoded | OpenAPI Parameter Style |
116
- * |--------------------------|---------------------------|--------------------------------|------------------------------------|
117
- * | `primitive` | `?a=1&a=2` | `{ a: '2' }` | `form` / `explode: false` |
118
- * | `array` | `?a=1&a=2` | `{ a: ['1', '2'] }` | `form` / `explode: true` |
119
- * | `comma-delimited-array` | `?a=1,2,3` | `{ a: ['1', '2', '3'] }` | `form` / `explode: false` |
120
- * | `comma-delimited-object` | `?a=A,1,B,2` | `{ a: { A: '1', B: '2' } }` | `form` / `explode: false` |
121
- * | `space-delimited-array` | `?a=1 2 3` | `{ a: ['1', '2', '3'] }` | `spaceDelimited` / `explode: false`|
122
- * | `space-delimited-object` | `?a=A 1 B 2` | `{ a: { A: '1', B: '2' } }` | `spaceDelimited` / `explode: false`|
123
- * | `pipe-delimited-array` | `?a=1\|2\|3` | `{ a: ['1', '2', '3'] }` | `pipeDelimited` / `explode: false` |
124
- * | `pipe-delimited-object` | `?a=A\|1\|B\|2` | `{ a: { A: '1', B: '2' } }` | `pipeDelimited` / `explode: false` |
125
- * | `json` | `?meta={"key":"value"}` | `{ meta: { key: 'value' } }` | `content: application/json` |
126
- * | _default_ | `?a[]=1&a[]=2&b=3&c[d]=4` | `{a:['1', '2'], b:3, c:{d:4}}` | `deepObject` / `explode: true` |
127
- *
128
- * **Strategy details:**
129
- *
130
- * - **`primitive`**: Takes the last occurrence of a repeated parameter.
131
- * - **`array`**: Always produces an array, even for a single occurrence.
132
- * - **`*-delimited-array`**: Splits the last value on the delimiter (`,`, space, or `|`) into an array.
133
- * - **`*-delimited-object`**: Splits the last value on the delimiter into alternating key–value pairs.
134
- * - **`json`**: Parses the last value as JSON; falls back to the raw string if parsing fails.
135
- * - **`undefined`**: Standard bracket-notation decoding This is the default.
136
- *
137
- * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
138
- *
139
- * @example
140
- * ```ts
141
- * // GET /search?keyword=abc&tags=a,b,c&meta={"key":"value"}
142
- * const queryParsing = {
143
- * keyword: 'primitive',
144
- * tags: 'comma-delimited-array',
145
- * meta: 'json',
146
- * }
147
- *
148
- * const inputSchema = z.object({
149
- * keyword: z.string(),
150
- * tags: z.array(z.string()),
151
- * meta: z.object({ key: z.string() }),
152
- * })
153
- * ```
154
- *
155
- * @default `undefined` for all parameters (bracket-notation decoding)
156
- */
157
- 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;
158
- /**
159
- * Hint for how to parse the incoming request body.
160
- *
161
- * Note: This option takes priority over the `standard-server` and `Content-Type` headers.
162
- * `form-data` and `url-search-params` are decoded using bracket notation,
163
- * so the resulting value will be an object or array.
164
- *
165
- * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
166
- */
167
- requestBodyHint?: StandardBodyHint | undefined;
168
- /**
169
- * Hint for how to parse a successful response body (status below 400).
170
- * Error response bodies are always parsed from their headers.
171
- *
172
- * Note: This option takes priority over the `standard-server` and `Content-Type` headers.
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
- * The operation object always follows OpenAPI 3.2, `OpenAPIGenerator` downgrades it with the
271
- * rest of the document when an older version is requested.
272
- *
273
- * **Merging**: When defined multiple times:
274
- *
275
- * - Two functions are chained: the most recent function receives the result of the previous one.
276
- * - A function combined with an object: the function is applied to that object.
277
- * - Two objects: the most recent object wins.
278
- *
279
- * Explicitly setting `undefined` resets the spec instead of merging.
280
- */
281
- spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]> | undefined;
282
- /**
283
- * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
284
- *
285
- * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
286
- * Explicitly setting `undefined` resets the prefix instead of merging.
287
- */
288
- prefix?: `/${string}` | undefined;
7
+ /**
8
+ * HTTP method accepted by this procedure.
9
+ *
10
+ * @default 'POST'
11
+ */
12
+ method?: "HEAD" | "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "QUERY" | undefined;
13
+ /**
14
+ * URL path for this procedure. Supports dynamic parameters via `{param}` syntax,
15
+ * and `{+param}` to allow slashes in the matched value.
16
+ *
17
+ * @example `/users`, `/users/{id}`, `/files/{+path}`
18
+ * @default Router segments joined by `'/`
19
+ */
20
+ path?: `/${string}` | undefined;
21
+ /**
22
+ * Unique identifier for this operation in the OpenAPI spec.
23
+ *
24
+ * @default Router segments joined by `.`
25
+ */
26
+ operationId?: string | undefined;
27
+ /**
28
+ * Short summary of the procedure, used as the operation summary in the generated spec.
29
+ */
30
+ summary?: string | undefined;
31
+ /**
32
+ * Detailed description of the procedure, used as the operation description in the generated spec.
33
+ */
34
+ description?: string | undefined;
35
+ /**
36
+ * Marks the procedure as deprecated in the generated spec.
37
+ */
38
+ deprecated?: boolean | undefined;
39
+ /**
40
+ * Tags associated with this procedure.
41
+ *
42
+ * **Merging**: When defined multiple times, tags are concatenated in definition order.
43
+ * Explicitly setting `undefined` resets the tags instead of merging.
44
+ */
45
+ tags?: string[] | undefined;
46
+ /**
47
+ * HTTP status code returned on success.
48
+ * Should be in the `2xx` range and must be less than `400`.
49
+ *
50
+ * @default 200
51
+ */
52
+ successStatus?: number | undefined;
53
+ /**
54
+ * Description of the successful response.
55
+ *
56
+ * @default 'OK'
57
+ */
58
+ successDescription?: string | undefined;
59
+ /**
60
+ * Controls how individual path parameters are decoded.
61
+ *
62
+ * **Merging**: When defined multiple times, styles are merged per parameter.
63
+ * The most recent style defined for a parameter wins.
64
+ * Explicitly setting `undefined` resets the styles instead of merging.
65
+ *
66
+ * Each key maps a path parameter name to one of the following strategies:
67
+ *
68
+ * | Strategy | Encoded path segment | Decoded | OpenAPI Parameter Style |
69
+ * |--------------------------|----------------------|------------------------------|----------------------------------|
70
+ * | `primitive` *(default)* | `/users/42` | `{ id: '42' }` | `simple` |
71
+ * | `comma-delimited-array` | `/users/a,b,c` | `{ id: ['a', 'b', 'c'] }` | `simple` |
72
+ * | `comma-delimited-object` | `/users/a,1,b,2` | `{ id: { a: '1', b: '2' } }` | `simple` |
73
+ *
74
+ * **Strategy details:**
75
+ *
76
+ * - **`primitive`**: Keeps the decoded path segment as a string.
77
+ * - **`comma-delimited-array`**: Splits the decoded path segment on `,` into an array.
78
+ * - **`comma-delimited-object`**: Splits the decoded path segment on `,` into alternating key-value pairs.
79
+ *
80
+ * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * // openapi.path = '/users/{id}/{tags}/{filters}'
85
+ * // GET /users/42/red,blue/size,large,brand,nike
86
+ *
87
+ * const paramsStyles = {
88
+ * id: 'primitive',
89
+ * tags: 'comma-delimited-array',
90
+ * filters: 'comma-delimited-object',
91
+ * }
92
+ *
93
+ * const inputSchema = z.object({
94
+ * id: z.string(),
95
+ * tags: z.array(z.string()),
96
+ * filters: z.object({
97
+ * size: z.string(),
98
+ * brand: z.string(),
99
+ * }),
100
+ * })
101
+ * ```
102
+ *
103
+ * @default `primitive` for all parameters
104
+ */
105
+ paramsStyles?: Record<string, "primitive" | "comma-delimited-array" | "comma-delimited-object" | undefined> | undefined;
106
+ /**
107
+ * Controls how individual query parameters are encoding/decoding.
108
+ *
109
+ * **Merging**: When defined multiple times, styles are merged per parameter.
110
+ * The most recent style defined for a parameter wins.
111
+ * Explicitly setting `undefined` resets the styles instead of merging.
112
+ *
113
+ * Each key maps a query parameter name to one of the following strategies:
114
+ *
115
+ * | Strategy | Encoded | Decoded | OpenAPI Parameter Style |
116
+ * |--------------------------|---------------------------|--------------------------------|------------------------------------|
117
+ * | `primitive` | `?a=1&a=2` | `{ a: '2' }` | `form` / `explode: false` |
118
+ * | `array` | `?a=1&a=2` | `{ a: ['1', '2'] }` | `form` / `explode: true` |
119
+ * | `comma-delimited-array` | `?a=1,2,3` | `{ a: ['1', '2', '3'] }` | `form` / `explode: false` |
120
+ * | `comma-delimited-object` | `?a=A,1,B,2` | `{ a: { A: '1', B: '2' } }` | `form` / `explode: false` |
121
+ * | `space-delimited-array` | `?a=1 2 3` | `{ a: ['1', '2', '3'] }` | `spaceDelimited` / `explode: false`|
122
+ * | `space-delimited-object` | `?a=A 1 B 2` | `{ a: { A: '1', B: '2' } }` | `spaceDelimited` / `explode: false`|
123
+ * | `pipe-delimited-array` | `?a=1\|2\|3` | `{ a: ['1', '2', '3'] }` | `pipeDelimited` / `explode: false` |
124
+ * | `pipe-delimited-object` | `?a=A\|1\|B\|2` | `{ a: { A: '1', B: '2' } }` | `pipeDelimited` / `explode: false` |
125
+ * | `json` | `?meta={"key":"value"}` | `{ meta: { key: 'value' } }` | `content: application/json` |
126
+ * | _default_ | `?a[]=1&a[]=2&b=3&c[d]=4` | `{a:['1', '2'], b:3, c:{d:4}}` | `deepObject` / `explode: true` |
127
+ *
128
+ * **Strategy details:**
129
+ *
130
+ * - **`primitive`**: Takes the last occurrence of a repeated parameter.
131
+ * - **`array`**: Always produces an array, even for a single occurrence.
132
+ * - **`*-delimited-array`**: Splits the last value on the delimiter (`,`, space, or `|`) into an array.
133
+ * - **`*-delimited-object`**: Splits the last value on the delimiter into alternating key–value pairs.
134
+ * - **`json`**: Parses the last value as JSON; falls back to the raw string if parsing fails.
135
+ * - **`undefined`**: Standard bracket-notation decoding This is the default.
136
+ *
137
+ * **Note**: `*-delimited-*` strategies do not support keys or values containing the delimiter character.
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * // GET /search?keyword=abc&tags=a,b,c&meta={"key":"value"}
142
+ * const queryParsing = {
143
+ * keyword: 'primitive',
144
+ * tags: 'comma-delimited-array',
145
+ * meta: 'json',
146
+ * }
147
+ *
148
+ * const inputSchema = z.object({
149
+ * keyword: z.string(),
150
+ * tags: z.array(z.string()),
151
+ * meta: z.object({ key: z.string() }),
152
+ * })
153
+ * ```
154
+ *
155
+ * @default `undefined` for all parameters (bracket-notation decoding)
156
+ */
157
+ 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;
158
+ /**
159
+ * Hint for how to parse the incoming request body.
160
+ *
161
+ * Note: This option takes priority over the `standard-server` and `Content-Type` headers.
162
+ * `form-data` and `url-search-params` are decoded using bracket notation,
163
+ * so the resulting value will be an object or array.
164
+ *
165
+ * @default Inferred from `Content-Type`, `Content-Disposition`, and `Content-Length`
166
+ */
167
+ requestBodyHint?: StandardBodyHint | undefined;
168
+ /**
169
+ * Hint for how to parse a successful response body (status below 400).
170
+ * Error response bodies are always parsed from their headers.
171
+ *
172
+ * Note: This option takes priority over the `standard-server` and `Content-Type` headers.
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
+ * The operation object always follows OpenAPI 3.2, `OpenAPIGenerator` downgrades it with the
271
+ * rest of the document when an older version is requested.
272
+ *
273
+ * **Merging**: When defined multiple times:
274
+ *
275
+ * - Two functions are chained: the most recent function receives the result of the previous one.
276
+ * - A function combined with an object: the function is applied to that object.
277
+ * - Two objects: the most recent object wins.
278
+ *
279
+ * Explicitly setting `undefined` resets the spec instead of merging.
280
+ */
281
+ spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]> | undefined;
282
+ /**
283
+ * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
284
+ *
285
+ * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
286
+ * Explicitly setting `undefined` resets the prefix instead of merging.
287
+ */
288
+ prefix?: `/${string}` | undefined;
289
289
  }
290
290
  export interface OpenAPIMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
291
- name: '~openapi';
291
+ name: "~openapi";
292
292
  }
293
293
  export interface OpenAPIMethodMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
294
- name: '~openapi/method';
294
+ name: "~openapi/method";
295
295
  }
296
296
  export interface OpenAPIPathMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
297
- name: '~openapi/path';
297
+ name: "~openapi/path";
298
298
  }
299
299
  export interface OpenAPISpecMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
300
- name: '~openapi/spec';
300
+ name: "~openapi/spec";
301
301
  }
302
302
  export interface OpenAPIPrefixMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
303
- name: '~openapi/prefix';
303
+ name: "~openapi/prefix";
304
304
  }
305
305
  export interface OpenAPIFunction {
306
- (meta: OpenAPIMeta): OpenAPIMetaPlugin<any, any, any>;
307
- method(method: OpenAPIMeta['method']): OpenAPIMethodMetaPlugin<any, any, any>;
308
- path(method: OpenAPIMeta['path']): OpenAPIPathMetaPlugin<any, any, any>;
309
- spec(method: OpenAPIMeta['spec']): OpenAPISpecMetaPlugin<any, any, any>;
310
- prefix(method: OpenAPIMeta['prefix']): OpenAPIPrefixMetaPlugin<any, any, any>;
306
+ (meta: OpenAPIMeta): OpenAPIMetaPlugin<any, any, any>;
307
+ method(method: OpenAPIMeta["method"]): OpenAPIMethodMetaPlugin<any, any, any>;
308
+ path(method: OpenAPIMeta["path"]): OpenAPIPathMetaPlugin<any, any, any>;
309
+ spec(method: OpenAPIMeta["spec"]): OpenAPISpecMetaPlugin<any, any, any>;
310
+ prefix(method: OpenAPIMeta["prefix"]): OpenAPIPrefixMetaPlugin<any, any, any>;
311
311
  }
312
312
  /**
313
313
  * Creates OpenAPI meta plugins that control how a procedure is exposed over HTTP,
@@ -322,4 +322,4 @@ export declare const openapi: OpenAPIFunction;
322
322
  *
323
323
  * @see {@link https://orpc.dev/docs/rpc/handler#enabling-the-get-method | RPC Handler - Enabling the GET Method}
324
324
  */
325
- export declare function getOpenAPIMeta(procedureOrLazy: AnyProcedureContract | Lazy<any>): OpenAPIMeta | undefined;
325
+ export declare function getOpenAPIMeta(procedureOrLazy: AnyProcedureContract | Lazy<any>): OpenAPIMeta | undefined;