@orpc/openapi 2.0.0-beta.4 → 2.0.0-beta.41

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 (45) hide show
  1. package/README.md +97 -94
  2. package/dist/adapters/aws-lambda/index.d.mts +26 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +26 -0
  4. package/dist/adapters/aws-lambda/index.mjs +21 -0
  5. package/dist/adapters/fastify/index.d.mts +23 -0
  6. package/dist/adapters/fastify/index.d.ts +23 -0
  7. package/dist/adapters/fastify/index.mjs +21 -0
  8. package/dist/adapters/fetch/index.d.mts +15 -5
  9. package/dist/adapters/fetch/index.d.ts +15 -5
  10. package/dist/adapters/fetch/index.mjs +6 -6
  11. package/dist/adapters/node/index.d.mts +9 -4
  12. package/dist/adapters/node/index.d.ts +9 -4
  13. package/dist/adapters/node/index.mjs +4 -4
  14. package/dist/adapters/standard/index.d.mts +10 -46
  15. package/dist/adapters/standard/index.d.ts +10 -46
  16. package/dist/adapters/standard/index.mjs +6 -6
  17. package/dist/extensions/route.d.mts +5 -7
  18. package/dist/extensions/route.d.ts +5 -7
  19. package/dist/helpers/index.d.mts +9 -1
  20. package/dist/helpers/index.d.ts +9 -1
  21. package/dist/helpers/index.mjs +1 -1
  22. package/dist/index.d.mts +77 -45
  23. package/dist/index.d.ts +77 -45
  24. package/dist/index.mjs +614 -765
  25. package/dist/plugins/index.d.mts +35 -6
  26. package/dist/plugins/index.d.ts +35 -6
  27. package/dist/plugins/index.mjs +15 -10
  28. package/dist/shared/{openapi.B2SK0ZAr.mjs → openapi.8cM6P94D.mjs} +32 -36
  29. package/dist/shared/openapi.B2G-HeFn.mjs +123 -0
  30. package/dist/shared/{openapi.7vgmPxca.d.ts → openapi.BCNfESWr.d.ts} +12 -9
  31. package/dist/shared/{openapi.CX6Ri5dP.d.mts → openapi.BgpM--nz.d.mts} +12 -9
  32. package/dist/shared/{openapi.CTlpLuKN.mjs → openapi.Bi1qxGF9.mjs} +102 -54
  33. package/dist/shared/{openapi.DmAa7YPO.mjs → openapi.Bu_PfTtX.mjs} +140 -61
  34. package/dist/shared/{openapi.C7m7NAmH.d.mts → openapi.C2LayTNZ.d.mts} +16 -5
  35. package/dist/shared/{openapi.C7m7NAmH.d.ts → openapi.C2LayTNZ.d.ts} +16 -5
  36. package/dist/shared/openapi.C6FFC29v.d.mts +31 -0
  37. package/dist/shared/openapi.C6FFC29v.d.ts +31 -0
  38. package/dist/shared/{openapi.BQzzr4-4.d.ts → openapi.Cem81Zhm.d.mts} +41 -12
  39. package/dist/shared/{openapi.BcEtAxQj.d.mts → openapi.Cem81Zhm.d.ts} +41 -12
  40. package/dist/shared/openapi.Cg9h6jpm.d.mts +45 -0
  41. package/dist/shared/openapi.D0yWs-uW.d.ts +45 -0
  42. package/package.json +57 -17
  43. package/dist/shared/openapi.Bt87OzTt.mjs +0 -131
  44. package/dist/shared/openapi.CYgMBSUF.d.mts +0 -18
  45. package/dist/shared/openapi.CYgMBSUF.d.ts +0 -18
@@ -1,4 +1,4 @@
1
- import { StandardBody } from '@standardserver/core';
1
+ import { StandardBody } from '@standard-server/core';
2
2
  import { Segment } from '@orpc/shared';
3
3
 
4
4
  type BracketNotationSerializeResult = [string, unknown][];
@@ -81,10 +81,10 @@ interface OpenAPIJsonSerializerOptions {
81
81
  *
82
82
  * **Disabling:** Set a key to `undefined` to remove a built-in handler:
83
83
  * ```ts
84
- * handlers: { regexp: undefined }
84
+ * handlers: { url: undefined }
85
85
  * ```
86
86
  *
87
- * Built-in type keys: `undefined`, `bigint`, `date`, `nan`, `url`, `regexp`, `set`, `map`.
87
+ * Built-in type keys: `undefined`, `bigint`, `date`, `nan`, `infinity`, `url`, `set`, `map`.
88
88
  */
89
89
  handlers?: Record<string, undefined | OpenAPIJsonSerializerHandler> | undefined;
90
90
  /**
@@ -95,10 +95,15 @@ interface OpenAPIJsonSerializerOptions {
95
95
  omitUndefinedProperties?: boolean | undefined;
96
96
  }
97
97
  declare class OpenAPIJsonSerializer {
98
- private readonly handlers;
98
+ private readonly inlineBuiltInHandlers;
99
+ private readonly handlerEntries;
99
100
  private readonly omitUndefinedProperties;
100
101
  constructor(options?: OpenAPIJsonSerializerOptions);
101
102
  serialize(data: unknown): OpenAPIJsonSerialization;
103
+ /**
104
+ * `segments` is a shared mutable stack (push/pop while walking),
105
+ * so it must be copied before being stored in `maps`.
106
+ */
102
107
  private serializeValue;
103
108
  deserialize(serialized: OpenAPIJsonSerialization): unknown;
104
109
  }
@@ -118,7 +123,7 @@ interface OpenAPISerializerSerializeOptions {
118
123
  */
119
124
  asFormData?: boolean | undefined;
120
125
  }
121
- interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions, OpenAPISerializerSerializeOptions {
126
+ interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions {
122
127
  /**
123
128
  * Options for bracket notation serializer, like maxExplicitDeserializingArrayIndex
124
129
  */
@@ -128,6 +133,12 @@ interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions, OpenAPI
128
133
  */
129
134
  serialize?: OpenAPISerializerSerializeOptions | undefined;
130
135
  }
136
+ /**
137
+ * Handles one-way serialization of oRPC payloads into JSON-friendly formats,
138
+ * partially supporting complex data types beyond plain JSON such as `Date`, `BigInt`, and `Set`.
139
+ *
140
+ * @see {@link https://orpc.dev/docs/openapi/serializer | OpenAPI Serializer}
141
+ */
131
142
  declare class OpenAPISerializer {
132
143
  private readonly jsonSerializer;
133
144
  private readonly bracketNotation;
@@ -0,0 +1,31 @@
1
+ import { OpenAPIV3_0, OpenAPIV3_1, OpenAPIV3_2 } from '@openapi-spec/types';
2
+ import { AnyNestedClient, Client, ORPCError } from '@orpc/client';
3
+ import { AsyncIteratorClass } from '@orpc/shared';
4
+
5
+ /**
6
+ * An OpenAPI version `OpenAPIGenerator` can target: any `3.0.x`, `3.1.x`, or `3.2.x` value.
7
+ *
8
+ * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
9
+ */
10
+ type OpenAPIVersion = `3.0.${number}` | `3.1.${number}` | `3.2.${number}`;
11
+ /**
12
+ * The OpenAPI document of the given version.
13
+ *
14
+ * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
15
+ */
16
+ type OpenAPIDocument<TVersion extends OpenAPIVersion> = TVersion extends `3.0.${string}` ? OpenAPIV3_0.OpenAPIObject : TVersion extends `3.1.${string}` ? OpenAPIV3_1.OpenAPIObject : OpenAPIV3_2.OpenAPIObject;
17
+ type JsonifiedValue<T> = T extends string | number | boolean | null | undefined ? T : T extends Date | bigint | URL ? string : T extends ReadonlyArray<unknown> ? JsonifiedArray<T> : T extends Blob | ReadonlyMap<any, any> | ReadonlySet<any> | AsyncIteratorObject<any, any, any> | Function ? T extends File ? File : T extends Blob ? Blob : T extends ReadonlyMap<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends ReadonlySet<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorClass<infer U, infer V> ? AsyncIteratorClass<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncGenerator<infer U, infer V> ? AsyncGenerator<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown : T extends object ? {
18
+ [K in keyof T]: JsonifiedValue<T[K]>;
19
+ } : unknown;
20
+ type JsonifiedArray<T extends ReadonlyArray<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [U extends undefined ? null : JsonifiedValue<U>, ...JsonifiedArray<V>] : T extends ReadonlyArray<infer U> ? Array<JsonifiedValue<U>> : unknown;
21
+ type JsonifiedClientError<T> = T extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : T;
22
+ /**
23
+ * Client type whose outputs and error data replace types JSON cannot represent with their JSON equivalents.
24
+ *
25
+ * @see {@link https://orpc.dev/docs/openapi/link | OpenAPI Link}
26
+ */
27
+ type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, JsonifiedClientError<UError>> : {
28
+ [K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
29
+ };
30
+
31
+ export type { JsonifiedClient as J, OpenAPIVersion as O, OpenAPIDocument as a, JsonifiedArray as b, JsonifiedClientError as c, JsonifiedValue as d };
@@ -0,0 +1,31 @@
1
+ import { OpenAPIV3_0, OpenAPIV3_1, OpenAPIV3_2 } from '@openapi-spec/types';
2
+ import { AnyNestedClient, Client, ORPCError } from '@orpc/client';
3
+ import { AsyncIteratorClass } from '@orpc/shared';
4
+
5
+ /**
6
+ * An OpenAPI version `OpenAPIGenerator` can target: any `3.0.x`, `3.1.x`, or `3.2.x` value.
7
+ *
8
+ * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
9
+ */
10
+ type OpenAPIVersion = `3.0.${number}` | `3.1.${number}` | `3.2.${number}`;
11
+ /**
12
+ * The OpenAPI document of the given version.
13
+ *
14
+ * @see {@link https://orpc.dev/docs/openapi/specification#openapi-version | OpenAPI Specification - OpenAPI Version}
15
+ */
16
+ type OpenAPIDocument<TVersion extends OpenAPIVersion> = TVersion extends `3.0.${string}` ? OpenAPIV3_0.OpenAPIObject : TVersion extends `3.1.${string}` ? OpenAPIV3_1.OpenAPIObject : OpenAPIV3_2.OpenAPIObject;
17
+ type JsonifiedValue<T> = T extends string | number | boolean | null | undefined ? T : T extends Date | bigint | URL ? string : T extends ReadonlyArray<unknown> ? JsonifiedArray<T> : T extends Blob | ReadonlyMap<any, any> | ReadonlySet<any> | AsyncIteratorObject<any, any, any> | Function ? T extends File ? File : T extends Blob ? Blob : T extends ReadonlyMap<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends ReadonlySet<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorClass<infer U, infer V> ? AsyncIteratorClass<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncGenerator<infer U, infer V> ? AsyncGenerator<JsonifiedValue<U>, JsonifiedValue<V>> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown : T extends object ? {
18
+ [K in keyof T]: JsonifiedValue<T[K]>;
19
+ } : unknown;
20
+ type JsonifiedArray<T extends ReadonlyArray<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [U extends undefined ? null : JsonifiedValue<U>, ...JsonifiedArray<V>] : T extends ReadonlyArray<infer U> ? Array<JsonifiedValue<U>> : unknown;
21
+ type JsonifiedClientError<T> = T extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : T;
22
+ /**
23
+ * Client type whose outputs and error data replace types JSON cannot represent with their JSON equivalents.
24
+ *
25
+ * @see {@link https://orpc.dev/docs/openapi/link | OpenAPI Link}
26
+ */
27
+ type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, JsonifiedClientError<UError>> : {
28
+ [K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
29
+ };
30
+
31
+ export type { JsonifiedClient as J, OpenAPIVersion as O, OpenAPIDocument as a, JsonifiedArray as b, JsonifiedClientError as c, JsonifiedValue as d };
@@ -1,8 +1,8 @@
1
1
  import { AnySchema, ErrorMap, MetaPlugin, AnyProcedureContract } from '@orpc/contract';
2
2
  import { Lazy } from '@orpc/server';
3
3
  import { Value } from '@orpc/shared';
4
- import { StandardBodyHint } from '@standardserver/core';
5
- import { O as OpenAPIOperationObject } from './openapi.CYgMBSUF.js';
4
+ import { StandardBodyHint } from '@standard-server/core';
5
+ import { OpenAPIV3_2 } from '@openapi-spec/types';
6
6
 
7
7
  interface OpenAPIMeta {
8
8
  /**
@@ -10,11 +10,12 @@ interface OpenAPIMeta {
10
10
  *
11
11
  * @default 'POST'
12
12
  */
13
- method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | undefined;
13
+ method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'QUERY' | undefined;
14
14
  /**
15
- * URL path for this procedure. Supports dynamic segments via `${}` syntax.
15
+ * URL path for this procedure. Supports dynamic parameters via `{param}` syntax,
16
+ * and `{+param}` to allow slashes in the matched value.
16
17
  *
17
- * @example `/users`, `/users/${id}`
18
+ * @example `/users`, `/users/{id}`, `/files/{+path}`
18
19
  * @default Router segments joined by `'/`
19
20
  */
20
21
  path?: `/${string}` | undefined;
@@ -39,11 +40,13 @@ interface OpenAPIMeta {
39
40
  /**
40
41
  * Tags associated with this procedure.
41
42
  *
42
- * **Note**: Tags are merged when defined multiple times.
43
+ * **Merging**: When defined multiple times, tags are concatenated in definition order.
44
+ * Explicitly setting `undefined` resets the tags instead of merging.
43
45
  */
44
46
  tags?: string[] | undefined;
45
47
  /**
46
- * HTTP status code returned on success. Must be in the 200–399 range.
48
+ * HTTP status code returned on success.
49
+ * Should be in the `2xx` range and must be less than `400`.
47
50
  *
48
51
  * @default 200
49
52
  */
@@ -57,7 +60,9 @@ interface OpenAPIMeta {
57
60
  /**
58
61
  * Controls how individual path parameters are decoded.
59
62
  *
60
- * **Note**: Param styles are merged when defined multiple times.
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.
61
66
  *
62
67
  * Each key maps a path parameter name to one of the following strategies:
63
68
  *
@@ -102,7 +107,9 @@ interface OpenAPIMeta {
102
107
  /**
103
108
  * Controls how individual query parameters are encoding/decoding.
104
109
  *
105
- * **Note**: Query styles are merged when defined multiple times.
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.
106
113
  *
107
114
  * Each key maps a query parameter name to one of the following strategies:
108
115
  *
@@ -260,13 +267,23 @@ interface OpenAPIMeta {
260
267
  * Pass a plain object to replace entire operation object, or a function that receives the current
261
268
  * operation object and returns the modified version.
262
269
  *
263
- * **Note**: Spec is merged when defined multiple times.
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.
264
280
  */
265
- spec?: Value<OpenAPIOperationObject, [current: OpenAPIOperationObject]>;
281
+ spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]>;
266
282
  /**
267
283
  * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
268
284
  *
269
- * **Note**: Prefixes are merged when defined multiple times.
285
+ * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
286
+ * Explicitly setting `undefined` resets the prefix instead of merging.
270
287
  */
271
288
  prefix?: `/${string}` | undefined;
272
289
  }
@@ -292,7 +309,19 @@ interface OpenAPIFunction {
292
309
  spec(method: OpenAPIMeta['spec']): OpenAPISpecMetaPlugin<any, any, any>;
293
310
  prefix(method: OpenAPIMeta['prefix']): OpenAPIPrefixMetaPlugin<any, any, any>;
294
311
  }
312
+ /**
313
+ * Creates OpenAPI meta plugins that control how a procedure is exposed over HTTP,
314
+ * such as its method, path, prefix, and OpenAPI operation spec.
315
+ *
316
+ * @see {@link https://orpc.dev/docs/openapi/routing | OpenAPI Routing}
317
+ * @see {@link https://orpc.dev/docs/openapi/specification | OpenAPI Specification}
318
+ */
295
319
  declare const openapi: OpenAPIFunction;
320
+ /**
321
+ * Retrieves the OpenAPI metadata attached to a procedure or router, or `undefined` if not set.
322
+ *
323
+ * @see {@link https://orpc.dev/docs/rpc/handler#enabling-the-get-method | RPC Handler - Enabling the GET Method}
324
+ */
296
325
  declare function getOpenAPIMeta(procedureOrLazy: AnyProcedureContract | Lazy<any>): OpenAPIMeta | undefined;
297
326
 
298
327
  export { getOpenAPIMeta as g, openapi as o };
@@ -1,8 +1,8 @@
1
1
  import { AnySchema, ErrorMap, MetaPlugin, AnyProcedureContract } from '@orpc/contract';
2
2
  import { Lazy } from '@orpc/server';
3
3
  import { Value } from '@orpc/shared';
4
- import { StandardBodyHint } from '@standardserver/core';
5
- import { O as OpenAPIOperationObject } from './openapi.CYgMBSUF.mjs';
4
+ import { StandardBodyHint } from '@standard-server/core';
5
+ import { OpenAPIV3_2 } from '@openapi-spec/types';
6
6
 
7
7
  interface OpenAPIMeta {
8
8
  /**
@@ -10,11 +10,12 @@ interface OpenAPIMeta {
10
10
  *
11
11
  * @default 'POST'
12
12
  */
13
- method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | undefined;
13
+ method?: 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'QUERY' | undefined;
14
14
  /**
15
- * URL path for this procedure. Supports dynamic segments via `${}` syntax.
15
+ * URL path for this procedure. Supports dynamic parameters via `{param}` syntax,
16
+ * and `{+param}` to allow slashes in the matched value.
16
17
  *
17
- * @example `/users`, `/users/${id}`
18
+ * @example `/users`, `/users/{id}`, `/files/{+path}`
18
19
  * @default Router segments joined by `'/`
19
20
  */
20
21
  path?: `/${string}` | undefined;
@@ -39,11 +40,13 @@ interface OpenAPIMeta {
39
40
  /**
40
41
  * Tags associated with this procedure.
41
42
  *
42
- * **Note**: Tags are merged when defined multiple times.
43
+ * **Merging**: When defined multiple times, tags are concatenated in definition order.
44
+ * Explicitly setting `undefined` resets the tags instead of merging.
43
45
  */
44
46
  tags?: string[] | undefined;
45
47
  /**
46
- * HTTP status code returned on success. Must be in the 200–399 range.
48
+ * HTTP status code returned on success.
49
+ * Should be in the `2xx` range and must be less than `400`.
47
50
  *
48
51
  * @default 200
49
52
  */
@@ -57,7 +60,9 @@ interface OpenAPIMeta {
57
60
  /**
58
61
  * Controls how individual path parameters are decoded.
59
62
  *
60
- * **Note**: Param styles are merged when defined multiple times.
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.
61
66
  *
62
67
  * Each key maps a path parameter name to one of the following strategies:
63
68
  *
@@ -102,7 +107,9 @@ interface OpenAPIMeta {
102
107
  /**
103
108
  * Controls how individual query parameters are encoding/decoding.
104
109
  *
105
- * **Note**: Query styles are merged when defined multiple times.
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.
106
113
  *
107
114
  * Each key maps a query parameter name to one of the following strategies:
108
115
  *
@@ -260,13 +267,23 @@ interface OpenAPIMeta {
260
267
  * Pass a plain object to replace entire operation object, or a function that receives the current
261
268
  * operation object and returns the modified version.
262
269
  *
263
- * **Note**: Spec is merged when defined multiple times.
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.
264
280
  */
265
- spec?: Value<OpenAPIOperationObject, [current: OpenAPIOperationObject]>;
281
+ spec?: Value<OpenAPIV3_2.OperationObject, [current: OpenAPIV3_2.OperationObject]>;
266
282
  /**
267
283
  * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
268
284
  *
269
- * **Note**: Prefixes are merged when defined multiple times.
285
+ * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
286
+ * Explicitly setting `undefined` resets the prefix instead of merging.
270
287
  */
271
288
  prefix?: `/${string}` | undefined;
272
289
  }
@@ -292,7 +309,19 @@ interface OpenAPIFunction {
292
309
  spec(method: OpenAPIMeta['spec']): OpenAPISpecMetaPlugin<any, any, any>;
293
310
  prefix(method: OpenAPIMeta['prefix']): OpenAPIPrefixMetaPlugin<any, any, any>;
294
311
  }
312
+ /**
313
+ * Creates OpenAPI meta plugins that control how a procedure is exposed over HTTP,
314
+ * such as its method, path, prefix, and OpenAPI operation spec.
315
+ *
316
+ * @see {@link https://orpc.dev/docs/openapi/routing | OpenAPI Routing}
317
+ * @see {@link https://orpc.dev/docs/openapi/specification | OpenAPI Specification}
318
+ */
295
319
  declare const openapi: OpenAPIFunction;
320
+ /**
321
+ * Retrieves the OpenAPI metadata attached to a procedure or router, or `undefined` if not set.
322
+ *
323
+ * @see {@link https://orpc.dev/docs/rpc/handler#enabling-the-get-method | RPC Handler - Enabling the GET Method}
324
+ */
296
325
  declare function getOpenAPIMeta(procedureOrLazy: AnyProcedureContract | Lazy<any>): OpenAPIMeta | undefined;
297
326
 
298
327
  export { getOpenAPIMeta as g, openapi as o };
@@ -0,0 +1,45 @@
1
+ import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
2
+ import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
3
+ import { RouterContract } from '@orpc/contract';
4
+ import { Value, Promisable, Public } from '@orpc/shared';
5
+ import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
6
+ import { O as OpenAPISerializer } from './openapi.C2LayTNZ.mjs';
7
+
8
+ interface OpenAPILinkCodecOptions<T extends ClientContext> {
9
+ /**
10
+ * Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
11
+ *
12
+ * @example '/api'
13
+ * @default '/'
14
+ */
15
+ url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
16
+ /**
17
+ * Inject headers into the request.
18
+ */
19
+ headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
20
+ /**
21
+ * Override the default OpenAPI serializer.
22
+ */
23
+ serializer?: Public<OpenAPISerializer>;
24
+ /**
25
+ * Customize how an error response body is converted into an ORPC error.
26
+ * Return `null` or `undefined` to fall back to the default decoding behavior.
27
+ */
28
+ customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
29
+ }
30
+ declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
31
+ private readonly router;
32
+ private readonly baseUrl;
33
+ private readonly headers;
34
+ private readonly serializer;
35
+ private readonly customErrorResponseBodyDecoder;
36
+ constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
37
+ encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
38
+ private encodePathParam;
39
+ private serializeQueryString;
40
+ decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
41
+ private resolveProcedure;
42
+ }
43
+
44
+ export { OpenAPILinkCodec as a };
45
+ export type { OpenAPILinkCodecOptions as O };
@@ -0,0 +1,45 @@
1
+ import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
2
+ import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
3
+ import { RouterContract } from '@orpc/contract';
4
+ import { Value, Promisable, Public } from '@orpc/shared';
5
+ import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
6
+ import { O as OpenAPISerializer } from './openapi.C2LayTNZ.js';
7
+
8
+ interface OpenAPILinkCodecOptions<T extends ClientContext> {
9
+ /**
10
+ * Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
11
+ *
12
+ * @example '/api'
13
+ * @default '/'
14
+ */
15
+ url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]>;
16
+ /**
17
+ * Inject headers into the request.
18
+ */
19
+ headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]>;
20
+ /**
21
+ * Override the default OpenAPI serializer.
22
+ */
23
+ serializer?: Public<OpenAPISerializer>;
24
+ /**
25
+ * Customize how an error response body is converted into an ORPC error.
26
+ * Return `null` or `undefined` to fall back to the default decoding behavior.
27
+ */
28
+ customErrorResponseBodyDecoder?: (deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined;
29
+ }
30
+ declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
31
+ private readonly router;
32
+ private readonly baseUrl;
33
+ private readonly headers;
34
+ private readonly serializer;
35
+ private readonly customErrorResponseBodyDecoder;
36
+ constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
37
+ encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
38
+ private encodePathParam;
39
+ private serializeQueryString;
40
+ decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
41
+ private resolveProcedure;
42
+ }
43
+
44
+ export { OpenAPILinkCodec as a };
45
+ export type { OpenAPILinkCodecOptions as O };
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.4",
4
+ "version": "2.0.0-beta.41",
5
+ "description": "Generate OpenAPI specs from oRPC routers and serve OpenAPI-compliant APIs with end-to-end type safety",
5
6
  "license": "MIT",
7
+ "funding": [
8
+ "https://github.com/sponsors/dinwwwh",
9
+ "https://opencollective.com/middleapi"
10
+ ],
6
11
  "homepage": "https://orpc.dev",
7
12
  "repository": {
8
13
  "type": "git",
@@ -11,7 +16,15 @@
11
16
  },
12
17
  "keywords": [
13
18
  "orpc",
14
- "openapi"
19
+ "rpc",
20
+ "api",
21
+ "typescript",
22
+ "typesafe",
23
+ "openapi",
24
+ "swagger",
25
+ "scalar",
26
+ "json-schema",
27
+ "rest"
15
28
  ],
16
29
  "sideEffects": [
17
30
  "./dist/extensions/route.mjs"
@@ -48,6 +61,16 @@
48
61
  "import": "./dist/adapters/node/index.mjs",
49
62
  "default": "./dist/adapters/node/index.mjs"
50
63
  },
64
+ "./aws-lambda": {
65
+ "types": "./dist/adapters/aws-lambda/index.d.mts",
66
+ "import": "./dist/adapters/aws-lambda/index.mjs",
67
+ "default": "./dist/adapters/aws-lambda/index.mjs"
68
+ },
69
+ "./fastify": {
70
+ "types": "./dist/adapters/fastify/index.d.mts",
71
+ "import": "./dist/adapters/fastify/index.mjs",
72
+ "default": "./dist/adapters/fastify/index.mjs"
73
+ },
51
74
  "./extensions/route": {
52
75
  "types": "./dist/extensions/route.d.mts",
53
76
  "import": "./dist/extensions/route.mjs",
@@ -57,26 +80,43 @@
57
80
  "files": [
58
81
  "dist"
59
82
  ],
83
+ "peerDependencies": {
84
+ "@scalar/api-reference": ">=1.57.2",
85
+ "@types/swagger-ui": ">=5.32.0",
86
+ "swagger-ui": ">=5.32.6"
87
+ },
88
+ "peerDependenciesMeta": {
89
+ "@scalar/api-reference": {
90
+ "optional": true
91
+ },
92
+ "@types/swagger-ui": {
93
+ "optional": true
94
+ },
95
+ "swagger-ui": {
96
+ "optional": true
97
+ }
98
+ },
60
99
  "dependencies": {
61
- "@hey-api/spec-types": "0.0.0-next-20260408030107",
62
- "@scalar/api-reference": "^1.57.2",
63
- "@standardserver/core": "^0.0.25",
64
- "@standardserver/fetch": "^0.0.25",
65
- "@types/swagger-ui": "^5.32.0",
66
- "rou3": "^0.8.1",
67
- "swagger-ui": "^5.32.6",
68
- "@orpc/client": "2.0.0-beta.4",
69
- "@orpc/contract": "2.0.0-beta.4",
70
- "@orpc/server": "2.0.0-beta.4",
71
- "@orpc/json-schema": "2.0.0-beta.4",
72
- "@orpc/shared": "2.0.0-beta.4"
100
+ "@openapi-spec/downgrader": "~0.1.0",
101
+ "@openapi-spec/types": "~0.1.0",
102
+ "@orpc/client": "2.0.0-beta.41",
103
+ "@orpc/contract": "2.0.0-beta.41",
104
+ "@orpc/json-schema": "2.0.0-beta.41",
105
+ "@orpc/server": "2.0.0-beta.41",
106
+ "@orpc/shared": "2.0.0-beta.41",
107
+ "@standard-server/core": "~0.10.0",
108
+ "@standard-server/fetch": "~0.10.0",
109
+ "rou3": "^0.9.1"
73
110
  },
74
111
  "devDependencies": {
75
- "fastify": "^5.6.2",
76
- "zod": "^4.4.3"
112
+ "@scalar/api-reference": "^1.65.1",
113
+ "@standard-server/aws-lambda": "~0.10.0",
114
+ "@types/swagger-ui": "^5.32.0",
115
+ "fastify": "^5.12.1",
116
+ "swagger-ui": "^5.32.14",
117
+ "zod": "^4.5.4"
77
118
  },
78
119
  "scripts": {
79
- "build": "unbuild",
80
120
  "type:check": "tsc -b"
81
121
  }
82
122
  }