@orpc/openapi 2.0.0-beta.19 → 2.0.0-beta.20

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.
@@ -40,7 +40,7 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
40
40
  * Mapping ORPCError Code -> HTTP Status Code
41
41
  * The status code should be in the `4xx` or `5xx` range (must be greater than or equal to `400`).
42
42
  *
43
- * @default COMMON_ERROR_STATUS_MAP, DEFAULT_ERROR_STATUS
43
+ * @default COMMON_ERROR_STATUS_MAP
44
44
  */
45
45
  errorStatusMap?: Record<string, number> | undefined;
46
46
  /**
@@ -40,7 +40,7 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
40
40
  * Mapping ORPCError Code -> HTTP Status Code
41
41
  * The status code should be in the `4xx` or `5xx` range (must be greater than or equal to `400`).
42
42
  *
43
- * @default COMMON_ERROR_STATUS_MAP, DEFAULT_ERROR_STATUS
43
+ * @default COMMON_ERROR_STATUS_MAP
44
44
  */
45
45
  errorStatusMap?: Record<string, number> | undefined;
46
46
  /**
@@ -4,7 +4,7 @@ import { unlazy } from '@orpc/server';
4
4
  import { value, pathToHttpPath, mergeHttpPath, isTypescriptObject, stringifyJSON } from '@orpc/shared';
5
5
  import { mergeStandardHeaders, parseStandardUrl, isStandardHeaders } from '@standardserver/core';
6
6
  import { toStandardHeaders } from '@standardserver/fetch';
7
- import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, g as getDynamicPathParams, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.Be9y-FmY.mjs';
7
+ import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, g as getDynamicPathParams, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.zZH_UksW.mjs';
8
8
  import { g as getOpenAPIMeta } from './openapi.B9PQzqBn.mjs';
9
9
 
10
10
  class OpenAPILinkCodecError extends TypeError {
@@ -56,7 +56,7 @@ class OpenAPILinkCodec {
56
56
  data = Object.keys(remaining).length > 0 ? remaining : void 0;
57
57
  }
58
58
  pathname = `${basePathname.replace(END_SLASH_REGEX, "")}${pathname}`;
59
- if (method === "GET") {
59
+ if (isBodylessMethod(method)) {
60
60
  const queryString2 = this.serializeQueryString(data, meta?.queryStyles);
61
61
  const search2 = combineSearch(baseSearch, queryString2);
62
62
  const url3 = `${pathname}${search2 ?? ""}${baseHash ?? ""}`;
@@ -110,7 +110,7 @@ class OpenAPILinkCodec {
110
110
  const queryString = this.serializeQueryString(input?.query, meta?.queryStyles);
111
111
  const search = combineSearch(baseSearch, queryString);
112
112
  const url = `${pathname}${search ?? ""}${baseHash ?? ""}`;
113
- if (method === "GET") {
113
+ if (isBodylessMethod(method)) {
114
114
  return {
115
115
  body: void 0,
116
116
  method,
@@ -2,7 +2,7 @@ import { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
2
2
  import { walkProcedureContractsSync, Procedure, unlazy, getRouter, createContractProcedure, DEFAULT_SUCCESS_STATUS, DEFAULT_ERROR_STATUS } from '@orpc/server';
3
3
  import { value, pathToHttpPath, mergeHttpPath, normalizeHttpPath, tryDecodeURIComponent, isPlainObject, stringifyJSON, parseEmptyableJSON, isTypescriptObject, NullProtoObj } from '@orpc/shared';
4
4
  import { parseStandardUrl, isStandardHeaders } from '@standardserver/core';
5
- import { D as DEFAULT_OPENAPI_METHOD, g as getDynamicPathParams, O as OpenAPISerializer, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.Be9y-FmY.mjs';
5
+ import { D as DEFAULT_OPENAPI_METHOD, g as getDynamicPathParams, O as OpenAPISerializer, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.zZH_UksW.mjs';
6
6
  import { g as getOpenAPIMeta } from './openapi.B9PQzqBn.mjs';
7
7
  import { createRouter, addRoute, findRoute, routeToRegExp } from 'rou3';
8
8
 
@@ -140,7 +140,7 @@ class OpenAPIHandlerCodecCore {
140
140
  const params = this.deserializeParams(matched.params, meta?.paramsStyles);
141
141
  const query = this.deserializeQuery(search, meta?.queryStyles);
142
142
  if (inputStructure === "compact") {
143
- const data = request.method === "GET" ? query : this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint));
143
+ const data = isBodylessMethod(request.method) ? query : this.serializer.deserialize(await request.resolveBody(meta?.requestBodyHint));
144
144
  if (data === void 0) {
145
145
  return params;
146
146
  }
@@ -40,7 +40,8 @@ interface OpenAPIMeta {
40
40
  /**
41
41
  * Tags associated with this procedure.
42
42
  *
43
- * **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.
44
45
  */
45
46
  tags?: string[] | undefined;
46
47
  /**
@@ -59,7 +60,9 @@ interface OpenAPIMeta {
59
60
  /**
60
61
  * Controls how individual path parameters are decoded.
61
62
  *
62
- * **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.
63
66
  *
64
67
  * Each key maps a path parameter name to one of the following strategies:
65
68
  *
@@ -104,7 +107,9 @@ interface OpenAPIMeta {
104
107
  /**
105
108
  * Controls how individual query parameters are encoding/decoding.
106
109
  *
107
- * **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.
108
113
  *
109
114
  * Each key maps a query parameter name to one of the following strategies:
110
115
  *
@@ -262,13 +267,20 @@ interface OpenAPIMeta {
262
267
  * Pass a plain object to replace entire operation object, or a function that receives the current
263
268
  * operation object and returns the modified version.
264
269
  *
265
- * **Note**: Spec is merged when defined multiple times.
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.
266
277
  */
267
278
  spec?: Value<OpenAPIOperationObject, [current: OpenAPIOperationObject]>;
268
279
  /**
269
280
  * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
270
281
  *
271
- * **Note**: Prefixes are merged when defined multiple times.
282
+ * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
283
+ * Explicitly setting `undefined` resets the prefix instead of merging.
272
284
  */
273
285
  prefix?: `/${string}` | undefined;
274
286
  }
@@ -40,7 +40,8 @@ interface OpenAPIMeta {
40
40
  /**
41
41
  * Tags associated with this procedure.
42
42
  *
43
- * **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.
44
45
  */
45
46
  tags?: string[] | undefined;
46
47
  /**
@@ -59,7 +60,9 @@ interface OpenAPIMeta {
59
60
  /**
60
61
  * Controls how individual path parameters are decoded.
61
62
  *
62
- * **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.
63
66
  *
64
67
  * Each key maps a path parameter name to one of the following strategies:
65
68
  *
@@ -104,7 +107,9 @@ interface OpenAPIMeta {
104
107
  /**
105
108
  * Controls how individual query parameters are encoding/decoding.
106
109
  *
107
- * **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.
108
113
  *
109
114
  * Each key maps a query parameter name to one of the following strategies:
110
115
  *
@@ -262,13 +267,20 @@ interface OpenAPIMeta {
262
267
  * Pass a plain object to replace entire operation object, or a function that receives the current
263
268
  * operation object and returns the modified version.
264
269
  *
265
- * **Note**: Spec is merged when defined multiple times.
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.
266
277
  */
267
278
  spec?: Value<OpenAPIOperationObject, [current: OpenAPIOperationObject]>;
268
279
  /**
269
280
  * Prefix for the path. Useful when you want to apply a common path prefix across multiple procedures.
270
281
  *
271
- * **Note**: Prefixes are merged when defined multiple times.
282
+ * **Merging**: When defined multiple times, prefixes are concatenated in definition order.
283
+ * Explicitly setting `undefined` resets the prefix instead of merging.
272
284
  */
273
285
  prefix?: `/${string}` | undefined;
274
286
  }
@@ -236,6 +236,9 @@ class OpenAPISerializer {
236
236
  }
237
237
  }
238
238
 
239
+ function isBodylessMethod(method) {
240
+ return method === "GET" || method === "HEAD";
241
+ }
239
242
  const PARAMETER_NAME_REGEX = /^[\w-]+$/;
240
243
  function getDynamicPathParams(path) {
241
244
  if (!path.includes("{")) {
@@ -272,4 +275,4 @@ function getDynamicPathParams(path) {
272
275
  return params;
273
276
  }
274
277
 
275
- export { DEFAULT_OPENAPI_METHOD as D, OpenAPISerializer as O, DEFAULT_OPENAPI_INPUT_STRUCTURE as a, DEFAULT_OPENAPI_OUTPUT_STRUCTURE as b, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION as c, OpenAPIJsonSerializer as d, getDynamicPathParams as g };
278
+ export { DEFAULT_OPENAPI_METHOD as D, OpenAPISerializer as O, DEFAULT_OPENAPI_INPUT_STRUCTURE as a, DEFAULT_OPENAPI_OUTPUT_STRUCTURE as b, DEFAULT_OPENAPI_SUCCESS_DESCRIPTION as c, OpenAPIJsonSerializer as d, getDynamicPathParams as g, isBodylessMethod as i };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.19",
4
+ "version": "2.0.0-beta.20",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -78,11 +78,11 @@
78
78
  "@standardserver/core": "^0.5.0",
79
79
  "@standardserver/fetch": "^0.5.0",
80
80
  "rou3": "^0.9.1",
81
- "@orpc/contract": "2.0.0-beta.19",
82
- "@orpc/json-schema": "2.0.0-beta.19",
83
- "@orpc/server": "2.0.0-beta.19",
84
- "@orpc/client": "2.0.0-beta.19",
85
- "@orpc/shared": "2.0.0-beta.19"
81
+ "@orpc/client": "2.0.0-beta.20",
82
+ "@orpc/contract": "2.0.0-beta.20",
83
+ "@orpc/server": "2.0.0-beta.20",
84
+ "@orpc/shared": "2.0.0-beta.20",
85
+ "@orpc/json-schema": "2.0.0-beta.20"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@scalar/api-reference": "^1.57.2",